PDO's SQLite extention has an odd bug whereby expressions with arguments are broken: General error: 25 bind or column index out of range. Damien has filed a bug report: http://bugs.php.net/bug.php?id=52746

However, EFQ still uses expressions with arguments in propertyQuery, and so that's broken. Since we can't fix the PHP bug, I've created a very small (and unfortunately ugly) workaround, that eliminates use of addExpression in EFQ.

Major as per http://drupal.org/node/45111:

An example would be a PHP error which is only triggered under rare circumstances or which affects only a small percentage of all users.

Comments

dmitrig01’s picture

ok, wtf. the logic around removing fields and expressions in count queries was inverted. Much saner patch now, no hacking around, just real fixing

dmitrig01’s picture

Explanation:

Before, count queries looked like this:

SELECT COUNT(*) FROM (SELECT x, y, 1 FROM z)

After:

SELECT COUNT(*) FROM (SELECT 1 FROM z)

While this in itself is not inherently buggy, just unnecessary, it was causing breakage on SQLite because of an obscure PHP bug.

chx’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

<humble mode> This happens when I am not involved with a DBTNG issue </humble mode>

To test, you can try to select a nonexisting field -- countquery should still work. Same with expression.

dmitrig01’s picture

Issue tags: -Needs tests
StatusFileSize
new2.76 KB
new1.8 KB

Tests fail in head and pass with patch, even with MySQL

dmitrig01’s picture

Status: Needs work » Needs review

chx++, btw

dmitrig01’s picture

with less spelling fail

chx’s picture

Status: Needs review » Reviewed & tested by the community

#4 shows how the patch fixed the issue, #6 just fixed a typo.

dmitrig01’s picture

oh wait, had a bit of redundancy

dmitrig01’s picture

Title: EntityFieldQuery uses addExpression, broken in SQLite » Count query fails to remove fields and expressions
chx’s picture

Title: Count query fails to remove fields and expressions » EntityFieldQuery uses addExpression, broken in SQLite

yeah right that does not affect the code flow though so still RTBC :)

dmitrig01’s picture

Title: EntityFieldQuery uses addExpression, broken in SQLite » Count query fails to remove fields and expressions
dmitrig01’s picture

And with comments

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Massaged the comment a bit (which I asked for in IRC cos I couldn't figure out what the heck that test was testing) and committed to HEAD.

dmitrig01’s picture

awesome -- thanks

damien tournoud’s picture

ew. That was a nasty one. I wonder, are we supporting DISTINCT properly for count queries? It feels to me that we shouldn't remove the fields for DISTINCT queries either.

dawehner’s picture

Status: Fixed » Needs review
StatusFileSize
new942 bytes

If you look at $group_by it is array(0, 1)

dawehner’s picture

StatusFileSize
new592 bytes

New version of the patch without debug code.

The problem was reported at #1005690: Argument summaries throw errors when combined with pagers

dawehner’s picture

Assigned: dmitrig01 » dawehner
Status: Needs review » Needs work

This needs testing

dmitrig01’s picture

Status: Needs work » Needs review
StatusFileSize
new2.21 KB
new2.97 KB

Status: Needs review » Needs work

The last submitted patch, test_only.patch, failed testing.

dmitrig01’s picture

Status: Needs work » Needs review

stupid bot, that was supposed to fail

chx’s picture

Status: Needs review » Reviewed & tested by the community

This is the problem reported by dereine, proven by the test, fixed by the patch.

quicksketch’s picture

I've marked my report at #1005690: Argument summaries throw errors when combined with pagers as duplicate. This patch corrects the original problem (Views arguments failing) for me also.

chx’s picture

I have reproduced the bug as described in #1005690: Argument summaries throw errors when combined with pagers , applied the patch, the problem went away. Video at http://drupal4hu.com/desktop_video.ogv

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD. Thanks a lot, folks. SO happy to not have another D7 RC that breaks Views. :P~

Crell’s picture

Status: Fixed » Active

And I be glad if I didn't have to remind people that we don't put Drupal-specific global functions into the middle of a DB layer class unless there is absolutely no other option. I don't believe this qualifies as "absolutely no other option".

I am not re-opening this issue because there's another follow-up already, but I am really getting sick and tired of being ignored. #1005674: SelectQuery::countQuery() fails with a group by expression

webchick’s picture

Status: Active » Fixed

I believe Crell's #27 is addressed by #1005674: SelectQuery::countQuery() fails with a group by expression, which I just committed.

Tentatively marking this back to fixed.

Crell, I don't think anyone is ignoring you. We just wanted to fix Views before RC3 and weren't taking all ramifications of the fix into consideration.

Status: Fixed » Closed (fixed)

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