Argument of AND must be type boolean, not type integer

Damien Tournoud - August 10, 2008 - 15:37
Project:Drupal
Version:7.x-dev
Component:search.module
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

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.

AttachmentSizeStatusTest resultOperations
search-postgres-and.patch880 bytesIgnoredNoneNone

#1

Dries - August 12, 2008 - 10:32

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

#2

Damien Tournoud - August 12, 2008 - 17:28

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.

#3

Dries - August 13, 2008 - 07:00

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

#4

chx - August 13, 2008 - 11:25

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.

#5

Freso - August 13, 2008 - 16:56
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?

#6

Anonymous (not verified) - August 27, 2008 - 17:02
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.