Per sql standards keywords should be upper case.

Currently coder module doesn't check for this, but it would be nice if it did.

In the same territory, coder misses the need for {} around table names..

Comments

douggreen’s picture

Status: Active » Needs review

I marked this as "code needs review" even though it is already committed. I marked it such so that it will get some testing, and additional community input.

I've added a basic sql review to both 5.x and 6.x. It catches some lower case keywords, and most unbracketed table names. It doesn't catch mixed case keywords, nor does it catch the multitude of valid SQL keywords. It basically looks for INSERT|UPDATE|SELECT|DELETE (with some additional words needed to make sure it's a SQL string instead of a help message). It doesn't catch unbracketed table names in joins.

I ran it against core, and it did fairly well, finding one real error in upload.module:

Line 419: table names should be enclosed in {curly_brackets}

  $result = db_query('SELECT DISTINCT f.* FROM upload u INNER JOIN files f ON u.fid = f.fid WHERE u.nid = %d', $node->nid);

But it also found some exceptions such as pg_proc in system.install and temp_search_sids in search.module. I'm not sure about pg_proc. I know that the temp_search_sids is actually OK as-is; but a case could be made to bracketing it for consistency -- even though this is just a temporary table.

I've marked it as a "new" review pending testing. Please test it. Once it's confirmed to work well, I'll remove the "new review" message.

greggles’s picture

Awesome - thanks Doug.

I've read several patches and seen discussions of several fixes to core which were found with this new feature. Well done.

douggreen’s picture

Status: Needs review » Fixed

As this has already been committed, and is now quite old, I'm marking as fixed.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.