fix: DB interface uses Type for regular tables, Encoded for join tables#31
Conversation
…hema.Encoded 5.7.0 flipped the DB interface to Schema.Schema.Encoded for all tables to fix the join-table column-name bug. That was correct for join tables (they use Schema.fromKey to remap A/B → semantic names; Encoded preserves real DB columns), but accidentally stripped branded IDs across all regular tables. Schema.Schema.Encoded strips Schema.brand(...) because brands live on the Type side. Fix: pick the side that matches the intended consumer view per table category. - Regular tables: Schema.Schema.Type — preserves branded IDs and ColumnType phantoms. Type === Encoded for column names anyway since regular tables don't use Schema.fromKey. - Join tables: Schema.Schema.Encoded — preserves real DB column names A/B. Type would expose Schema.fromKey-decoded names that Kysely passes to SQL verbatim → "column does not exist". Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
5.7.0 flipped the DB interface to
Schema.Schema.Encodedfor all tables to fix the join-table column-name bug (_product_tags.product_idwas decoded-name; SQL needsA). That was right for join tables but accidentally stripped branded IDs for regular tables —Schema.Schema.Encoded<typeof X>stripsSchema.brand(...)because brands live on the Type side.Concrete consequence: every Kysely consumer queried
result.seller_id: stringinstead ofresult.seller_id: string & Brand<\"SellerId\">. Branded ID type safety silently disabled across the entire monorepo.Fix
Pick the side per table category:
Schema.Schema.Type<typeof X>— preserves branded IDs (string & Brand<\"SellerId\">) andColumnType<S, I, U>phantoms. Type === Encoded for column names anyway because regular tables don't useSchema.fromKey.Schema.Schema.Encoded<typeof X>— preserves real DB column namesA/B. Type would expose decoded names that Kysely passes to SQL verbatim → "column does not exist".Tests
db-interface-sql-contract.test.tsupdated to assert both: regular tables useType, join tables useEncoded. The Kysely SQL-compile test (catches the original join-table bug at the SQL level) stays.Migration
Regular-table consumers regain
Brand<...>IDs immediately. Join-table consumers (_product_tags.A/Bqueries) unchanged from 5.7.0.🤖 Generated with Claude Code