ignore autoinc column on update
See original GitHub issueWe are ignoring autoinc column for inserts, we could to the same for updates. Either like this:
FoobarTable.filter(_.id === someFoobar.id).update(someFoobar)
where newRow’s autoinc column is automatically excluded or even like this
FoobarTable.update(someFoobar)
where it is automatically used as a discriminator (as requested in #570).
Issue Analytics
- State:
- Created 10 years ago
- Reactions:4
- Comments:14 (6 by maintainers)
Top Results From Across the Web
tell mysql to ignore updates/inserts for auto increment values
Is there a way to tell mysql to ignore any tentative to assign any value to an auto-increment column?. We are using slick...
Read more >Avoiding auto-increment holes on InnoDB with INSERT IGNORE
A simple INSERT IGNORE query creates gaps for every ignored insert, ... ON DUPLICATE KEY UPDATE produce gaps on the auto_increment column.
Read more >13.2.7.2 INSERT ... ON DUPLICATE KEY UPDATE Statement
If a table contains an AUTO_INCREMENT column and INSERT ... ON DUPLICATE KEY UPDATE inserts or updates a row, the LAST_INSERT_ID() function returns...
Read more >How to update an existing row in the table when you do insert.
ON DUPLICATE KEY UPDATE always increments the auto-increment column by 1. ... If you use INSERT IGNORE, the existing record is updated anyway....
Read more >INSERT ON DUPLICATE KEY UPDATE - MariaDB
It returns the column values from the INSERT portion of the statement. This function is particularly useful for multi-rows inserts. The IGNORE and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Apparently, it’s still missing even in 3.2.1. Is there is any hope that it’ll show up in the next release?
It’s still not clear - at least to me - if this issue is really an improvement or if it should have been labeled with some higher priority instead.
True fact is that Slick is generating erroneous SQL for a very specific RDBMS - SQLServer in this case - and such problematic generation could well be avoided using the metadata we have in our hands.
It may well be the very legitimate case to put the responsibility on the user. After all he/she is defining an action that instructs Slick to update all the record’s columns. But on the other hand, we know before hand that auto-inc columns are probably to be left untouched - especially in this case where erroneous SQL is generated for this particular RDBMS.
We should also no forget that - as @cvogt mentions in the first comment - we are already “ignoring autoinc column for inserts”. In order to keep things consistent, shouldn’t this update() action also exclude auto-inc columns?
Should this be enough to force a new Release Candidate for 3.2.0? I understand that the combination of Slick + SQLServer + need for the update() action probably represents a little percentage of the overall use cases, but nevertheless it feels like something is being released with a well known issue left unresolved.