[dev] [cvs] commit: turba/lib/Driver sql.php

Matt Selsky selsky at columbia.edu
Tue Oct 30 05:03:08 UTC 2007


On Oct 29, 2007, at 11:27 PM, Chuck Hagenbuch wrote:

> Quoting Matt Selsky <selsky at columbia.edu>:
>
>>> http://cvs.horde.org/diff.php/turba/lib/Driver/sql.php? 
>>> r1=1.102&r2=1.103&ty=u
>>
>> Will '!=' cause problems for bind variables here?  Do we need to use
>> '<>' instead?
>
> Huh? Why would it? We don't avoid this anywhere else that I'm aware  
> of.

The generated query is:

SELECT object_id, object_type, owner_id, object_name, object_bday
FROM turba_objects
WHERE (owner_id = ? AND object_bday <> ?)
	AND object_bday IS NOT NULL
	AND SUBSTR(object_bday, 6, 5) BETWEEN ? AND ?

Without the '<>', the query would be '!=' and that could trip up the  
bind parser and quoting, aka, it produces the following incorrect SQL  
query:

SELECT object_id, object_type, owner_id, object_name, object_bday
FROM turba_objects
WHERE (owner_id = ? AND object_bday \!= ?)
	AND object_bday IS NOT NULL
	AND SUBSTR(object_bday, 6, 5) BETWEEN ? AND ?

Also, why do we need to check for object_bday != '' and object_bday  
IS NOT NULL?  The IS NOT NULL check should be sufficient.


-- 
Matt




More information about the dev mailing list