Skip to content

Follow-ups: dependency bump, README parity note, CHECK constraint translation - #155

Open
davidpavlovschi wants to merge 3 commits into
parity/upstream-2026-07from
followups/deps-readme-check
Open

Follow-ups: dependency bump, README parity note, CHECK constraint translation#155
davidpavlovschi wants to merge 3 commits into
parity/upstream-2026-07from
followups/deps-readme-check

Conversation

@davidpavlovschi

@davidpavlovschi davidpavlovschi commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

This is the follow-up batch I promised in #152 and #153, on top of the parity port. Three
independent commits, each reviewable on its own.

Dependencies. gorm.io/gorm 1.25.7 to 1.31.2 and github.com/glebarez/go-sqlite 1.21.2 to
1.22.0, which moves modernc.org/sqlite 1.23.1 to 1.28.0. go mod tidy refreshes the indirect
set. The go directive stays at 1.18: gorm 1.31.2 declares go 1.18 and go-sqlite 1.22.0 declares
go 1.17, so nothing forces a raise and the driver keeps its wide support floor. No test outcome
changed across the bump.

README. A short "Upstream parity" section recording the last upstream commit merged here
(525c431), the three divergences that are deliberate and will stay (pure-Go backend imports,
DriverName defaulting to sqlite, and Translate reading the extended result code off the
driver error instead of marshalling to JSON), and the rule I committed to in #152: anything that
does not depend on the backend goes to go-gorm/sqlite first and comes back here as a port. The
first one is go-gorm#247.

CHECK constraints. SQLITE_CONSTRAINT_CHECK, extended code 275, fell through Translate
and reached the caller as a raw driver error, so anyone running with TranslateError: true had
to string-match "CHECK constraint failed" to detect it. UNIQUE, PRIMARY KEY and FOREIGN KEY were
already mapped, so this closes the gap against gorm.ErrCheckConstraintViolated. This mirrors
the follow-up to go-gorm#247.

The test runs against a real in-memory database: it migrates a model carrying a CHECK
constraint, asserts the constraint actually landed in the table DDL so a failure for the wrong
reason cannot pass, then inserts a violating row. With the mapping reverted it fails with the
raw error and code 275.

go test ./... goes from 15 tests to 16, 70 to 71 counting subtests, no failures. gofmt,
go vet ./... and CGO_ENABLED=0 go build ./... are clean.

Risks

  1. modernc.org/sqlite 1.23.1 to 1.28.0 is the real risk in the batch, not gorm. It is the
    embedded SQLite engine, five minor versions, and it also raises the embedded SQLite library
    version, which the README's version badge reports. The fork's own 16 tests pass, but they do
    not exercise the engine the way the CI job does. The gate is the GORM 12k-test suite in CI,
    which cannot run locally here. Do not merge on local green alone.
  2. Sequencing against Port 11 behaviour fixes from go-gorm/sqlite (parity with upstream) #153 and ci: test against Go 1.24-1.26, matching upstream #154. This branch is based on parity/upstream-2026-07, so it
    has to land after Port 11 behaviour fixes from go-gorm/sqlite (parity with upstream) #153. Rebase onto master once Port 11 behaviour fixes from go-gorm/sqlite (parity with upstream) #153 merges on Aug 3. ci: test against Go 1.24-1.26, matching upstream #154 raises the CI matrix
    to Go 1.24 through 1.26; a go 1.18 directive still builds under those, so no conflict, but
    the two PRs touch CI expectations from opposite sides.
  3. Open dependabot PRs now conflict. build(deps): bump gorm.io/gorm from 1.25.7 to 1.25.10 #135 (gorm to 1.25.10), build(deps): bump modernc.org/sqlite from 1.23.1 to 1.29.6 #131 (modernc.org/sqlite to
    1.29.6) and build(deps): bump github.com/glebarez/go-sqlite from 1.21.2 to 1.22.0 #115 (go-sqlite to 1.22.0) are all superseded or overshot by this bump. build(deps): bump modernc.org/sqlite from 1.23.1 to 1.29.6 #131 in
    particular wants modernc.org/sqlite 1.29.6, which is ahead of the 1.28.0 that go-sqlite 1.22.0
    pins. Close them with a pointer to this PR rather than merging in either order.
  4. The CHECK mapping is a behaviour change for existing callers. Anyone on TranslateError: true who today catches the raw driver error, or string-matches the message, now receives
    gorm.ErrCheckConstraintViolated instead. It is the correct behaviour and it matches the other
    three constraint kinds, but it is not strictly backward compatible and belongs in release notes.
  5. The README parity note goes stale on its own. It names commit 525c431 as the merge point,
    and nothing enforces that. It needs updating on every future parity port.

gorm.io/gorm 1.25.7 to 1.31.2, github.com/glebarez/go-sqlite 1.21.2 to
1.22.0, which pulls modernc.org/sqlite 1.23.1 to 1.28.0. go mod tidy
refreshes the indirect set. The go directive stays at 1.18: gorm 1.31.2
declares go 1.18 and go-sqlite 1.22.0 declares go 1.17, so nothing forces
a raise.

Test counts are unchanged, 15 top-level tests and 70 including subtests,
all passing.

Refs #152
States the last upstream commit merged (525c431), the three divergences
that are deliberate (pure-Go backend imports, DriverName "sqlite",
error-code-based Translate), and the rule that backend-agnostic fixes go
to go-gorm/sqlite first and come back as ports.

Refs #152
SQLITE_CONSTRAINT_CHECK (extended code 275) fell through Translate and
reached the caller as a raw driver error, so TranslateError users had to
string-match "CHECK constraint failed" to detect it. UNIQUE, PRIMARY KEY
and FOREIGN KEY were already mapped.

The test drives a real in-memory database: it migrates a model carrying a
CHECK constraint, asserts the constraint is in the table DDL so a wrong
failure cannot pass for the right one, then inserts a row that violates
it. Without the mapping the test fails with the raw error, code 275.

This mirrors the backport of the go-gorm#247 follow-up.

Refs #152
@davidpavlovschi

Copy link
Copy Markdown
Collaborator Author

Same environmental CI red as #153: old Go matrix vs new macOS runners. All ubuntu lanes pass. Goes green once #154 lands and this rebases.

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