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

ennorehling created an issue. See original summary.

ennorehling’s picture

Issue summary: View changes
ennorehling’s picture

I believe you are correct. I'll follow the progress on those issues.

longwave’s picture

Status: Active » Closed (duplicate)

Thanks for confirming, this can be closed.