-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Searching fails with pagination #70
Comments
I've narrowed down what I think is the issue,
|
This is the culprit: simplemap/src/services/MapService.php Lines 258 to 266 in e3cbea8
A field’s Element queries aren’t ever built and executed directly, though. They create an internal Query object, accessible via $query->query->join( should do the trick. |
I seem to have fixed the issue by replacing $query
->subQuery
->andWhere($restrict)
->andWhere("$distanceSearch <= $radius"); with $tableName = MapRecord::$tableName;
$query
->subQuery
->join(
JOIN',
"{$tableName} simplemap",
[
'and',
'[[elements.id]] = [[simplemap.ownerId]]',
'[[elements_sites.siteId]] = [[simplemap.ownerSiteId]]',
]
)
->andWhere($restrict)
->andWhere("$distanceSearch <= $radius"); I'm not sure if this is the perfect fix, but it's at least got the pagination working for me until the next release. |
If it helps, I'm getting a completely different error 😄
while @brandonkelly's fix gives me
and your fix, @lukeyouell, throws
Could you give me an example of your template code, and let me know what versions of Craft & SimpleMap you're running and what DB driver you're using? |
Template code: {% paginate craft.entries.section('propertyFeed').propertyLocation({
location: filter.location,
radius: filter.radius,
unit: 'mi'
})
.propertyPrice(filter.budget)
.propertyType(filter.type)
.propertyBedrooms(filter.bedrooms)
.propertyBathrooms(filter.bathrooms)
.orderBy(filter.sort).limit(6) as page, properties
%} Craft 3 RC-5 |
Hmm... I have a fix, but it only seems to work with MySQL. Postgres keeps throwing this error (fresh install, RC5):
The fix is basically what Brandon suggested, but extended to the subQuery as well (a tab is 4 spaces GitHub 😠 ): simplemap/src/services/MapService.php Lines 258 to 266 in e3cbea8
with $on = [
'and',
'[[elements.id]] = [[simplemap.ownerId]]',
'[[elements_sites.siteId]] = [[simplemap.ownerSiteId]]',
];
$query->query->join(
'JOIN',
"{$tableName} simplemap",
$on
);
$query->subQuery->join(
'JOIN',
"{$tableName} simplemap",
$on
); @brandonkelly Can you shed any light on the error above? |
@Tam that works for me! |
Issue doesn’t seem to be resolved. Could anyone point to a solution? Many thanks! Database used: PostgreSQL 11 Template code:
|
The following database exception is thrown when trying to paginate search results:
The text was updated successfully, but these errors were encountered: