Skip to content

generics: populate WithResult error#7723

Open
qqxhb wants to merge 1 commit intomasterfrom
fix/withresult-error
Open

generics: populate WithResult error#7723
qqxhb wants to merge 1 commit intomasterfrom
fix/withresult-error

Conversation

@qqxhb
Copy link
Member

@qqxhb qqxhb commented Mar 6, 2026

Fix mismatch with gorm.io Create docs generics example: WithResult() now exposes Error and it is populated when statement execution fails.

Changes:

  • Add Error field to WithResult result and reset it per statement.
  • Populate result.Error via DB.AddError when a WithResult result is attached.
  • Add sqlite-based unit test covering success + failure cases.

Tests:

  • go test ./...

Add Error field to WithResult result and set it via AddError; include a sqlite-based test.
@propel-code-bot
Copy link
Contributor

This update specifically aligns WithResult behavior for Create statements so execution errors are surfaced when a result is attached.

Affected Areas

generics.go
gorm.go
generics_withresult_test.go

This summary was automatically generated by @propel-code-bot

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