Repository navigation
Fix: generateTables failing on a CREATE INDEX over a missing column - #194
Merged
Merged
Conversation
An existing table without a column added to the entity later (not added by `CREATE TABLE IF NOT EXISTS`) made its generated `CREATE INDEX` fail (PostgreSQL: `42703: column "..." does not exist`), aborting the initialization before `checkTables` could report it. - `DBSQLAdapter.populateTables`: a failing `CREATE INDEX` over columns missing in its (existing) table is skipped, with a warning, when `checkTables` is pending: it reports the missing columns (and indexes), with the SQLs to fix them. Without `checkTables`: an error naming them. - New `DBSQLAdapter.extractCreateIndexInSQL`. - Tests: SQLite unit tests, and a shared adapter test (PostgreSQL and MySQL via Docker, SQLite, memory), including a boot with `generateTables` + `checkTables` over the outdated table. - Version 1.28.1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #194 +/- ##
==========================================
+ Coverage 95.62% 95.70% +0.08%
==========================================
Files 75 75
Lines 25754 25775 +21
==========================================
+ Hits 24627 24669 +42
+ Misses 1127 1106 -21
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Problem
An existing table missing a column that was added to the entity later, with an index over that column, failed the initialization in
generateTables(seen on PostgreSQL):CREATE TABLE IF NOT EXISTSdoesn't add the column, so itsCREATE INDEXfailed and the initialization was aborted beforecheckTablescould report the missing column with the SQLs to fix it.Fix
DBSQLAdapter.populateTables: when aCREATE INDEXfails, the indexed columns are checked against the existing table (getTableFieldsTypesImpl, not cached):checkTablespending: the index is skipped with a warning.checkTablesthen reports the missing columns and indexes, with the fix SQLs, e.g. on PostgreSQL:checkTables: an error naming the missing columns.Error creating table SQL).New
DBSQLAdapter.extractCreateIndexInSQL(table and plain columns of aCREATE INDEX;nullfor expressions).Tests
runAdapterTests), run for PostgreSQL and MySQL (Docker), SQLite and memory:address.cityand its indexes removed (an outdated table). On PostgreSQL/MySQL withgenerateTables+checkTables, a new provider is booted over it:generateTablespasses,checkTablesfails, and its suggested SQLs fix the table.42703/Error creating table SQLas in production.bones_api_cov_sqlite_test.dart):extractCreateIndexInSQL, the skip, the error withoutcheckTables, and the boot scenario.ensure_buildtoo, after the commit).Version bumped to 1.28.1 (1.28.0 already tagged), with its CHANGELOG section.
🤖 Generated with Claude Code