If the query that is sent to db_rewrite_sql contains WHERE or JOIN clauses that are spelled using lower case letters ('where', 'join'), the output SQL is malformed.

This is because:
1) Line 219 in database.inc (_db_rewrite_sql) attempts to extract the WHERE clause looking for an upper case keyword
2) Subsequently, the pattern at ine 324 in database.inc (db_rewrite_sql) incorrectly performs a regexp search, assuming again that all keywords are upper case.

I think that assuming that module developers write SQL correctly is a bad practice. Possible solution: A regexp that would process the query before attempting to explode / implode it, converting all SQL keywords to uppercase.

Comments

ohnobinki’s picture

I don't see any problem with this supposed bug. Case insensitivity means (unnoticeably) more processing. Also, I see no reason to avoid enforcing the proper style of writing SQL.

What we need is the documentation to state that properly-formatted SQL is required and describe that this implies capitalized JOIN and WHERE and whatnot.

Status: Active » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.