Skip to content

Conversation

@TimvdHeijden
Copy link
Contributor

Upsert operations failed with IDENTITY_INSERT is not set error when using IDENTITY (auto-increment) columns as id_field.

Solution

  • Detects IDENTITY columns via sys.identity_columns query
  • Raises descriptive error with actionable alternatives (use method='append', use non-IDENTITY columns, or enable preserve_identity=True)
  • New preserve_identity parameter wraps MERGE with SET IDENTITY_INSERT ON/OFF when explicitly enabled
  • Logs warning about sequence generation risks

Benefits

  • Prevents silent failures, educates users on best practices, maintains backward compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant