This code fails against MySQL (10.1.33-MariaDB):
db_select('sslcerts', 'ssl')->fields('ssl')->execute()->fetchAllAssoc('id');
The SQL statement it creates is approximately SELECT ssl.* FROM sslcerts ssl;. MySQL is not happy with this, and says:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ssl.* from users ssl' at line 1
I suspect that SSL is a reserved keyword in MySQL, or something? If I use any other table alias, things are working fine. It also accepts my query when I put backticks around the offending word, like so: SELECT `ssl`.* FROM sslcerts `ssl`;. However, this isn't how Drupal core builds the query, which is what I would suggest as a fix.
Not sure if this is a bug report or feature request, to be honest. Maybe it's just MySQL being :poop:
Comments
Comment #2
ennorehling commentedComment #3
longwaveI think this is a duplicate of #2986452: Database reserved keywords need to be quoted as per the ANSI standard and/or #2978575: Mysql 8 Support on Drupal 7
Comment #4
ennorehling commentedI believe you are correct. I'll follow the progress on those issues.
Comment #5
longwaveThanks for confirming, this can be closed.