[kronolith] SIMILAR TO in DB query ...
Marc G. Fournier
scrappy at hub.org
Tue Jul 29 19:12:37 PDT 2003
Doesn't show any errors on the front end, but the backend is reporting:
Jul 30 01:32:17 demo HORDE[5834]: [kronolith] DB Error: syntax error: SELECT DISTINCT a.category_id, c.category_name FROM horde_category_attributes a LEFT JOIN horde_categories c ON a.category_id = c.category_id WHERE c.group_uid = 'horde.shares.kronolith' AND ((attribute_name = 'owner' AND attribute_value = 'demo at demo.hub.org') OR (attribute_name = 'perm_users' AND attribute_key = 'demo at demo.hub.org' AND CASE WHEN CAST(attribute_value AS VARCHAR) SIMILAR TO '(-[0-9]+|[0-9]+)' THEN (CAST(attribute_value AS INTEGER) & 2) <> 0 ELS
DB Server is PostgreSQL v7.3.3 ... CVS HEAD as of today ...
The file its called in is lib/SQL.php, right at the top:
case 'pgsql':
// This should conform completely to SQL99.
return sprintf('CASE WHEN CAST(%s AS VARCHAR) SIMILAR TO \'(-[0-9]+|[0-9]+)\' THEN (CAST(%s AS INTEGER) %s %d) <> 0 ELSE FALSE END', $lhs, $lhs, $op, (int)$rhs);
Or, rather, where its appended ... not sure where its being called from
though ...
Now, the only examples I can find in teh docs for use of a CASE statement
in a SELECT is as part of the SELECT list, but never as part of the WHERE
clause ...
More information about the kronolith
mailing list