Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@boostvolt
Copy link

@boostvolt boostvolt commented Nov 17, 2025

Fixes #3675

UpdateNewValues() was incorrectly overwriting existing database values with default values when those fields were not explicitly set in the upsert operation.

The issue occurred because defaults() runs before SQL generation, adding default values to the mutation. The callback then saw these fields as "set" and included them in the UPDATE clause, overwriting existing database values.

Solution:

  • Pre-capture field states BEFORE defaults() runs for fields with Default()
  • Use ResolveWithNewValues() path for entities without standalone defaults
  • Only use pre-capture approach when entity has fields with Default() (excluding Immutable and UpdateDefault fields, which work correctly)

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.

UpdateNewValues updates the defaults (even when they are not set explicitely)

1 participant