Option for not inserting primary keys into Sql Server tables #1343
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Inserting values into IDENTITY columns on SQL Server (MS) will result in SQL Error:
insert explicit value for identity column in table 'tablename' when IDENTITY_INSERT is set to OFF
The are valid scenarios where you don´t want to (or cannot) alter the target tables of database just to "make kafka-connect happy".
But you might need to include the primary key in you kafka-connect config because you have to include it for the upsert mode/UPDATE case.
Related to #1287 and #837
Solution
Added option mssql.insert.primary.keys which defaults to true.
If set to false the INSERT will omit the primary key columns. This allows allows the database to create its own primary keys, if they are configured with IDENTITY(n,n) for autoincremental keys. This works for mode=insert and mode=upsert
Does this solution apply anywhere else?
If yes, where?
Test Strategy
Testing done:
Release Plan
This feature is non-breaking by design. Given there is no bug, it will not change any existing behavior. So it can be released without any migration effort.