Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query binding - long names with funcs #1353

Closed
nowackipawel opened this issue Oct 25, 2018 · 1 comment
Closed

Query binding - long names with funcs #1353

nowackipawel opened this issue Oct 25, 2018 · 1 comment

Comments

@nowackipawel
Copy link
Contributor

I am not sure if it is important enough but anyway there are cases when query binding does not work - i.e. long field "names" like:

CONCAT(`my_long_table_alias_name`.`hex_system_name`, IF (`my_long_table_alias_name`.`hex_name` IS NULL, '', CONCAT(' (', `my_long_table_alias_name`.`hex_name`, ')')))

should be replaced with `%test%'

i.e.:

SELECT `my_long_table_alias_name`.`hex_id`                                                                                 AS `id`,
       CONCAT(`my_long_table_alias_name`.`hex_system_name`, IF(`my_long_table_alias_name`.`hex_name` IS NULL, '',
                                                                CONCAT(' (', `my_long_table_alias_name`.`hex_name`, ')'))) AS `name`
FROM `my_test_table` AS `my_long_table_alias_name`
WHERE LOWER(CONCAT(`my_long_table_alias_name`.`hex_system_name`, IF(`my_long_table_alias_name`.`hex_name` IS NULL, '',
                                                                     CONCAT(' (', `my_long_table_alias_name`.`hex_name`, ')')))) LIKE
      :CONCAT(`my_long_table_alias_name`.`hex_system_name`, IF (`my_long_table_alias_name`.`hex_name` IS NULL, '', CONCAT(' (', `my_long_table_alias_name`.`hex_name`, ')'))):ESCAPE '!'

when I changed my code to generate shorter queries/table aliases it worked as excepted:

SELECT `Sa18bcd35ea`.`hex_id`                                                                           AS `id`,
       CONCAT(`Sa18bcd35ea`.`hex_system_name`, IFNULL(CONCAT(' (', `Sa18bcd35ea`.`hex_name`, ')'), '')) AS `name`
FROM `t_hb_example` AS `Sa18bcd35ea`
WHERE LOWER(CONCAT(`Sa18bcd35ea`.`hex_system_name`, IFNULL(CONCAT(' (', `Sa18bcd35ea`.`hex_name`, ')'), ''))) LIKE
      '%test%' ESCAPE '!';
@jim-parry
Copy link
Contributor

You are running into a MYSQL limitation, where the maximum length of most identifiers is 64 characters... https://dev.mysql.com/doc/refman/8.0/en/identifiers.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants