Activedataprovider set limit inside of query with union but should outside
Open
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 216
- Forks
- 51
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 2
Description
What steps will reproduce the problem?
$query = Product::find()->where(['id' => 1]);
$query2 = Product::find()->where(['id' => 2]);
$query-> union($query2);
$provider = new ActiveDataProvider([
'query' => $query,
'pagination' => [
'pageSize' => 12,
],
]);
$provider->getModels();
What is the expected result?
(SELECT * FROM product WHERE id=1) UNION ( SELECT * FROM product WHERE id=2 ) LIMIT 12
What do you get instead?
(SELECT * FROM product WHERE id=1 LIMIT 12) UNION ( SELECT * FROM product WHERE id=2 )
Additional info
| Q | A |
|---|---|
| Yii version | 2.0.? |
| PHP version | |
| Operating system |
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported ActiveDataProvider query with the union and pagination snippet, then trace how getModels() applies the page size and how the union is rendered. Done means the generated SQL places LIMIT 12 after the complete UNION rather than inside the first SELECT.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, sql
- Domain
- database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100