fix: suppress redundant UNIQUE on primary key fields in SQL exports#998
Open
20syldev wants to merge 1 commit intodrawdb-io:mainfrom
Open
fix: suppress redundant UNIQUE on primary key fields in SQL exports#99820syldev wants to merge 1 commit intodrawdb-io:mainfrom
20syldev wants to merge 1 commit intodrawdb-io:mainfrom
Conversation
PRIMARY KEY already implies uniqueness in all SQL databases. Emitting UNIQUE on a column that is also part of the PRIMARY KEY creates a redundant duplicate index, impacting performance. Fixes drawdb-io#961
|
@20syldev is attempting to deploy a commit to the dottle's projects Team on Vercel. A member of the Team first needs to authorize it. |
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
PRIMARY KEYalready implies uniqueness in all SQL databases (MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, Oracle)primary: trueandunique: true, the export was emittingUNIQUEon the column definition and aPRIMARY KEY(...)clause at the end of theCREATE TABLE, resulting in a redundant duplicate indexUNIQUEkeyword when the field is already marked as primary in all SQL exporters (mysql.js,mariadb.js,postgres.js,mssql.js,sqlite.js,oraclesql.js,generic.js)Root cause
Template files (
template1.jsthroughtemplate6.js) setunique: trueon primary key fields. The SQL export logic didn't account for this redundancy.Test plan
UNIQUEin its column definitionPRIMARY KEY(...)clause is still present at the end ofCREATE TABLEFixes #961