Add method batchUpdate in \yii\db\QueryBuilder
Open
Nobody has claimed this yet.
severity:BC breaking
- Dominant language
- PHP
- Stars
- 216
- Forks
- 51
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 2
Description
Very often in practice I have to do a bulk update of rows.
IN PostgreSQL:
UPDATE table AS t
SET
col1 = c.col1,
col2 = c.col2
FROM (VALUES (1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4) ) AS c (id, col1, col2)
WHERE c.id = t.id;
or
INSERT INTO table (id, col1, col2)
VALUES (1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4)
ON CONFLICT (id) DO UPDATE SET
col1 = EXCLUDED.col1,
col2 = EXCLUDED.col2
IN MySQL:
INSERT INTO table (id, col1, col2)
VALUES (1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4)
ON DUPLICATE KEY UPDATE
col1 = VALUES(col1),
col2 = VALUES(col2);
I'm sure other databases have similar capabilities.
For each DBMS will have its own specific implementation of the method batchUpdate in descendant classes.
Sorry for my bad english.
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 with the \yii\db\QueryBuilder entry point and inspect its descendant classes for database-specific implementations. Compare the PostgreSQL and MySQL SQL examples in the issue, then define the shared batchUpdate API and determine how each DBMS implementation should be validated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, php, postgresql, sql
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100