PostgreSQL (at least on 8.3), returns an error when AND is used between and integer and a boolean. The search module is bitten by that, because it sometimes generates queries such as:

SELECT xxx FROM yyy WHERE 1 AND (i.word = ?)

Here is a patch.

CommentFileSizeAuthor
search-postgres-and.patch880 bytesdamien tournoud

Comments

dries’s picture

A better solution might be to remove the WHERE 1 or the WHERE 1 = 1?

damien tournoud’s picture

This will be much simpler to do as part of #258998: do_search refactoring: performance, legibility, move validation to validation/submit handlers of form., I will post a note there.

In the meantime, I would like to see the simple fix here committed, as it probably breaks search on 6.x.

dries’s picture

OK, let's go with this fix for the time being. Committed to CVS HEAD and DRUPAL-6. Thanks.

chx’s picture

If postgresql can't take 1 for TRUE then it's broken and we should drop support. Not for the first time we committed a hack just to support a database where the theory fanatics so galopped away that it's no longer useable for a web app.

Edit: why a web app? Because with a web app, much less than a desktop app, you need casting all the time -- whatever comes from the browser is a string etc.

Freso’s picture

Status: Needs review » Fixed

If the work-around has been committed and the proper fix will be a part of #258998: do_search refactoring: performance, legibility, move validation to validation/submit handlers of form., isn't this fixed now?

Anonymous’s picture

Status: Fixed » Closed (fixed)

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