Posted by friedjoff on August 24, 2012 at 10:09am
4 followers
| Project: | Nodetype access |
| Version: | 7.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
For anonymous users and empty nodetype_acces permissions I get the following error message (I'm using PostgreSQL 8.4):
PDOException: SQLSTATE[42804]: Datatype mismatch: 7 ERROR: argument of AND must be type boolean, not type integer LINE 6: WHERE (promote = '1') AND (status = '1') AND (0) ) subquery ^: SELECT COUNT(*) AS expression FROM (SELECT 1 AS expression FROM {node} n WHERE (promote = :db_condition_placeholder_0) AND (status = :db_condition_placeholder_1) AND (0) ) subquery; Array ( [:db_condition_placeholder_0] => 1 [:db_condition_placeholder_1] => 1 ) in PagerDefault->execute() (line 74 of .../drupal/includes/pager.inc).
Comments
#1
This patch fixes the PDOException. Maybe I'm missing something, but I don't see the value of the removed where condition. Might be a PostgreSQL specific issue.
#2
you read my answer in the other issue #1426702: EFQ test fails for empty nodetype array?
this should already be fixed in current dev and release.
please always use latest version.
feel free to reopen if this does not apply.
#3
Yes, I'm using a current git checkout.
#4
As far as I can see the issue still exists in the current git HEAD.
The problem is that postgresql has a stricter typesystem than mysql. Using the '0'
in a boolean comparison like the module does in the following where-condition
(promote = :db_condition_placeholder_0) AND (status = :db_condition_placeholder_1) AND (0)
will result in a comparison of the following types:
(bool) AND (bool) AND (integer)
This comparison is not possible as postgresql does not have a default cast for casting integers
to boolean values.
A fix which will work on both database systems is providing a expression instead of the '0'. The expression '1=0'
will evaluate to False in both databases and preserve the same query the module currently creates, while
also making it work on postgresql.
#5
Just noticed I attached the wrong patch in comment #4.
This is the correct one.
#6
great work nico. committed and released.
#7
Automatically closed -- issue fixed for 2 weeks with no activity.