Skip to content

queryScalar - check subquery before changing params#15223

Merged
brandonkelly merged 3 commits into4.xfrom
bugfix/15001-subquery-checks
Jun 18, 2024
Merged

queryScalar - check subquery before changing params#15223
brandonkelly merged 3 commits into4.xfrom
bugfix/15001-subquery-checks

Conversation

@i-just
Copy link
Copy Markdown
Contributor

@i-just i-just commented Jun 18, 2024

Description

When running a query through our version of queryScalar, check if the subquery doesn’t have distinct, groupBy, having or union and only overwrite its select, orderBy, limit, and offset params if it doesn’t.

Related issues

#15001

@i-just i-just requested a review from brandonkelly June 18, 2024 15:01
@brandonkelly brandonkelly changed the base branch from 5.x to 4.x June 18, 2024 16:20
@brandonkelly brandonkelly merged commit 5e0dbea into 4.x Jun 18, 2024
@brandonkelly brandonkelly deleted the bugfix/15001-subquery-checks branch June 18, 2024 18:02
@samhibberd
Copy link
Copy Markdown

@brandonkelly does this also impact the exists() query method, since upgrading to 4.10.x which introduced this logic to work off the subquery:

try {
return $this->prepareSubquery()
->select('elements.id')
->exists($db);
} catch (QueryAbortedException) {
return false;
}

We are running into the same issue with the exists method when a HAVING clause is used (for us with simplemap ethercreative/simplemap#391 (comment))

@brandonkelly
Copy link
Copy Markdown
Member

@samhibberd Craft 4.10.8 and 5.2.10 are out with a fix for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants