Access allows us to INSERT arbitrary values into an AutoNumber column, similar to what T-SQL can do with SET IDENTITY_INSERT ... ON. It would be nice if Jackcess had a similar option.
Would you be okay with a database/table flag which allows "unsafe" inserts (similar to disabling foreign key checking)? where the default behavior stays the same?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hmm, good question. T-SQL only allows IDENTITY_INSERT to be enabled for one table at a time, but I've not seen an explanation of why that restriction is in place (though I've never really looked for one). Per-table would probably be safer and more flexible (e.g. for "unsafe" inserts into one table and "safe" inserts into others), provided that it's not a huge PITA to implement.
Last edit: Gord Thompson 2015-04-08
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Would you be okay with a database/table flag which allows "unsafe" inserts (similar to disabling foreign key checking)? where the default behavior stays the same?
Yes, that sounds like a good approach.
would you need to set this on a per-table basis, or only at the database level?
Hmm, good question. T-SQL only allows IDENTITY_INSERT to be enabled for one table at a time, but I've not seen an explanation of why that restriction is in place (though I've never really looked for one). Per-table would probably be safer and more flexible (e.g. for "unsafe" inserts into one table and "safe" inserts into others), provided that it's not a huge PITA to implement.
Last edit: Gord Thompson 2015-04-08
The ability to directly insert/update autonumbers can now be selectively enabled per-jvm (using a system property), per-database, and per-table.
fixed in trunk, will be in the 2.1.1 release.