-
Notifications
You must be signed in to change notification settings - Fork 11k
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
[5.8] Add INSERT IGNORE support to Query Builder #29572
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 <mail@jonas-staudenmeir.de>
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 ignore
on conflict do nothing
insert or ignore
merge
Example:
Others have voiced support for this feature: #9612
Also fixes laravel/ideas#1762