Skip to content

fix: isolate zero-value Model on Statement clone#7729

Closed
qqxhb wants to merge 1 commit intomasterfrom
fix/issue-7725-stale-where
Closed

fix: isolate zero-value Model on Statement clone#7729
qqxhb wants to merge 1 commit intomasterfrom
fix/issue-7725-stale-where

Conversation

@qqxhb
Copy link
Member

@qqxhb qqxhb commented Mar 12, 2026

Fixes #7725.
When Statement.clone() reuses the same zero-value *Model pointer (e.g. Model(&User{})) across cloned sessions, the update path can write the primary key back into that shared Model, and subsequent clones may append a stale pk predicate into WHERE
This isolates Model() only when it is a pointer to a zero-value struct, preventing cross-call contamination while leaving non-zero models untouched.
Tests: go test ./...

Prevent stale primary-key WHERE leaking across cloned sessions during Updates.

Fixes #7725
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.

Using Model with Session() cloning causes stale WHERE conditions in subsequent Updates() calls

1 participant