-
Notifications
You must be signed in to change notification settings - Fork 642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ElementQuery fails if both join
and search
are set
#4788
Comments
I am not really sure why this is a minor bug. The code that causes the error only uses methods described in the official Craft documentation: https://docs.craftcms.com/v3/dev/element-queries/#executing-element-queries (Also our customer does not think it's a minor issue 😉) I've created a pull request that solves that issue for us, but as the element query is such an important service in Craft it probably has to be triple-checked. |
It was minor in that it’s not a bug you would run into under normal circumstances; most people are not ever overriding the Entry::find()
->search('Some query string')
->andWhere('[[content.dateCreated]] < NOW()')
->all(); Still, it’s been fixed for the next release. To get the fix early, change your "require": {
"craftcms/cms": "dev-develop#82e14b2c1be3c9afeac9dbfb751f63da707153b9 as 3.2.10",
"...": "..."
} Then run |
Thank you very much for looking into it! Obviously the example code did not make much sense, in our real code a custom table is joined. I wanted to simplify the code so it shows the error without any prerequisites. |
Ah ok gotcha. Appreciate it, as I was able to reproduce with something similar, which was enough to warrant the bug fix :) |
Description
When combining both
join
andsearch
options in an element query a database exception will be thrown.Steps to reproduce
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'myContent.dateCreated' in 'where clause'
Background
The class
ElementQuery
will apply the search parameter in the methodprepare
before the join parameters are applied. The method_applySearchParam
will execute the current query in its intermediate, unfinished state causing the exception.Additional info
The text was updated successfully, but these errors were encountered: