-
-
Notifications
You must be signed in to change notification settings - Fork 12
Quote columns and table name #154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -23,7 +23,6 @@ | |||||
| using System.Data.Common; | ||||||
| using System.IO; | ||||||
| using System.Linq; | ||||||
| using System.Reflection; | ||||||
| using System.Text; | ||||||
| using ForeignKeyConstraint = DotNetProjects.Migrator.Framework.ForeignKeyConstraint; | ||||||
| using ForeignKeyConstraintType = DotNetProjects.Migrator.Framework.ForeignKeyConstraintType; | ||||||
|
|
@@ -416,7 +415,7 @@ | |||||
| // Remove the primary key notation if compound primary key because we'll add it back later | ||||||
| if (compoundPrimaryKey && column.IsPrimaryKey) | ||||||
| { | ||||||
| column.ColumnProperty = column.ColumnProperty ^ ColumnProperty.PrimaryKey; | ||||||
| column.ColumnProperty = column.ColumnProperty | ColumnProperty.NotNull; // PK is always not-null | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -725,6 +724,9 @@ | |||||
| /// <param name="columns">Primary column names</param> | ||||||
| public virtual void AddPrimaryKey(string name, string table, params string[] columns) | ||||||
| { | ||||||
| QuoteColumnNamesIfRequired(columns); | ||||||
| table = QuoteTableNameIfRequired(table); | ||||||
|
|
||||||
| ExecuteNonQuery( | ||||||
| string.Format("ALTER TABLE {0} ADD CONSTRAINT {1} PRIMARY KEY ({2}) ", table, name, | ||||||
| string.Join(",", QuoteColumnNamesIfRequired(columns)))); | ||||||
|
|
@@ -735,8 +737,7 @@ | |||||
| } | ||||||
| public virtual void AddUniqueConstraint(string name, string table, params string[] columns) | ||||||
| { | ||||||
| QuoteColumnNames(columns); | ||||||
|
|
||||||
| QuoteColumnNamesIfRequired(columns); | ||||||
| table = QuoteTableNameIfRequired(table); | ||||||
|
|
||||||
| ExecuteNonQuery(string.Format("ALTER TABLE {0} ADD CONSTRAINT {1} UNIQUE({2}) ", table, name, string.Join(", ", columns))); | ||||||
|
||||||
| ExecuteNonQuery(string.Format("ALTER TABLE {0} ADD CONSTRAINT {1} UNIQUE({2}) ", table, name, string.Join(", ", columns))); | |
| ExecuteNonQuery(string.Format("ALTER TABLE {0} ADD CONSTRAINT {1} UNIQUE({2}) ", table, name, string.Join(", ", QuoteColumnNamesIfRequired(columns)))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Column names are being quoted twice. The call to
QuoteColumnNamesIfRequired(columns)on line 727 modifies the array in-place, but then line 732 callsQuoteColumnNamesIfRequired(columns)again on the already-quoted column names. This will result in double-quoting. Either remove line 727 or use the array directly in line 732 without calling the method again.