fix(driver-sql): materialize declared object-level indexes (#1459)#1461
Merged
Conversation
The SQL driver synced columns and field-level `unique`, but silently
dropped object-level declared `indexes` ([{ fields, unique }]). As a
result documented multi-column UNIQUE guarantees (notification delivery
dedup, receipt upserts, dedup_key convergence, api_key/slug uniqueness)
were never enforced at the DB level — a fresh `dev --fresh` sqlite DB
showed only PK autoindexes.
Wire declared-index sync into `initObjects`:
- materialize single- and multi-column indexes after the table is
created/altered, including UNIQUE
- NULL-distinct semantics are the cross-dialect default, so multiple
NULL rows stay insertable while non-NULL duplicates are rejected
- idempotent: deterministic, length-bounded index names + per-dialect
existing-index introspection (sqlite/pg/mysql); "already exists" races
are absorbed
- indexes referencing a non-materialized (virtual/formula) column are
skipped with a warning instead of failing sync
Flip the `indexes` capability flag to true and add tests asserting the
index is materialized (PRAGMA index_list), rejects duplicates, allows
multiple NULLs, covers compound + non-unique indexes, and is idempotent.
https://claude.ai/code/session_01AgJ1guiaybKRbMfqAPCDeN
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
xuyushun441-sys
pushed a commit
that referenced
this pull request
Jun 2, 2026
Merge pull request #1461 from objectstack-ai/feat/gallery-cover-polish objectui@382df5d30075385f637c5925775790173ecc855e
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1459. The SQL driver synced columns and field-level
unique, but silently dropped object-level declaredindexes(ObjectSchema.indexes: [{ fields, unique }]). As a result several documented multi-column UNIQUE / dedup guarantees were never enforced at the DB level — a freshdev --freshsqlite DB showed only PK autoindexes.Affected guarantees that depended on an unenforced index:
sys_notification_deliveryUNIQUE(notification_id, recipient_id, channel)— outboxenqueue()convergence-on-conflictsys_notification_receiptUNIQUE(notification_id, user_id, channel)— bell mark-read / inbox delivered-receipt upsertssys_notification.dedup_keyUNIQUE(feat(messaging): race-safe dedup + opt-in retention (ADR-0030 hardening) #1458) —emit()dedup race-safetysys_api_key.key,sys_organization.slug, and other platform objects' declared unique indexesChanges
Wired declared-index sync into
initObjects(syncDeclaredIndexes):UNIQUE.PRAGMA index_list/pg_indexes/information_schema.STATISTICS). An "already exists" race is absorbed.formula) column are skipped with a warning instead of failing sync.Flipped the
indexescapability flagfalse → true.Tests
Added 7 tests to
sql-driver-schema.test.ts, all asserting viaPRAGMA index_liston a fresh in-memory sqlite DB:initObjectsrunssupports.indexes === trueFull
driver-sqlsuite: 132 passed. Package builds clean (ESM/CJS/DTS).Notes
Postgres/MySQL paths use the same knex
alterTable+ introspection helpers but were not exercised in CI here (no live PG/MySQL in this environment). The implementation is dialect-portable; a Postgres assertion can be added if a fixture is available.https://claude.ai/code/session_01AgJ1guiaybKRbMfqAPCDeN
Generated by Claude Code