Repository navigation
Keep constraints when editing tables that use ON CONFLICT on CHECK or NULL - #4242
Open
deepsidhu1313 wants to merge 4 commits into
Open
deepsidhu1313 wants to merge 4 commits into
deepsidhu1313 wants to merge 4 commits into
Conversation
QCOMPARE() cannot deduce the type of a bare braced-init-list in Qt6, so spell out sqlb::StringVector for the rowidColumns() comparisons.
Check that the conflict action of column and table PRIMARY KEY, NOT NULL and UNIQUE constraints survives parsing a CREATE TABLE statement and writing it out again, for every conflict action, and that it also survives the kind of edits the Edit Table dialog applies to a copy of the table before DBBrowserDB::alterTable() recreates it from the generated SQL (renaming the table or columns, changing or dropping columns, extending the key). Related: sqlitebrowser#1264
SQLite accepts a conflict clause after a table CHECK constraint and after the NULL column constraint, but our grammar rejected both. A table using either was then not fully parsed, so the Edit Table dialog could only offer the columns reported by the pragma and recreating the table from that dropped all of its constraints. Accept the clause in both places. For CHECK it is kept and written out again, so the definition isn't changed; for NULL, which isn't stored in the model at all, it is ignored just like the constraint itself. Related: sqlitebrowser#1264
Switching a constraint between Unique and Primary Key in the Edit Table dialog replaces it by a new constraint, which only copied the name. The ON CONFLICT clause of the old constraint was silently dropped. Carry it over and update the primary key's "On Conflict" combo box accordingly. Related: sqlitebrowser#1264
This branch has not been deployed
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.
SQLite accepts CHECK(expr) ON CONFLICT x at table level and NULL ON CONFLICT x on a column. Our grammar rejected both, so such a table counted as not fully parsed and any edit in the Edit Table dialog rebuilt it from the pragma name and type only, silently dropping every constraint (PRIMARY KEY, NOT NULL, UNIQUE, CHECK). The grammar now accepts both (CheckConstraint gets a conflict action). The dialog also keeps the conflict action when an index constraint is switched between Unique and Primary Key.
New tests in test-sqlobjects (7 failed before; 285 pass now). The first commit (Qt6 compile fix for test-sqlobjects) can be dropped if Qt6 work lands separately.
Refs #1264