[5.8] Add INSERT IGNORE support to Query Builder#29572
[5.8] Add INSERT IGNORE support to Query Builder#29572dunhamjared wants to merge 17 commits intolaravel:5.8from dunhamjared:5.8
Conversation
|
Your test is incorrect: MySQL uses backticks instead of double quotes (as shown in the error message). |
|
|
This is pretty cool, though I can't say I've personally reached for insert-ignore all that often. It assumes that on key conflict you are no longer wanting to update/refresh the values your inserting - this is often not what you want. A more useful strategy is |
|
I use For example: CREATE TABLE `test` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`foo` VARCHAR(50) NOT NULL DEFAULT '',
`bar` VARCHAR(50) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE INDEX `foo_bar` (`foo`, `bar`)
);INSERT IGNORE INTO test (foo, bar) VALUES ('A', 'A'), ('A', 'B'), ('A', 'C');
INSERT IGNORE INTO test (foo, bar) VALUES ('B', 'A'), ('A', 'B'), ('B', 'C');No need to use |
|
Yeah it's useful in cases like that. Maybe the method could be called
|
|
@garygreen The method should now read |
|
@staudenmeir Thank you for the input.
|
Co-Authored-By: Jonas Staudenmeir <[email protected]>
|
Resubmit without SQL Server support for this. It's the least used driver and I'm not adding parameters to the query builder just to support SQL Server. |
|
@taylorotwell probably wasn't nesscary to close the PR, could of just asked the OP to amend. Jared has been very been responsive in suggestions. |
This pull request adds insert or ignore support to Query Builder for the following database engines:
insert ignoreon conflict do nothinginsert or ignoremergeExample:
Others have voiced support for this feature: #9612
Also fixes laravel/ideas#1762