File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -162,7 +162,7 @@ func parseDDL(strs ...string) (*ddl, error) {
162162 for _ , column := range getAllColumns (matches [1 ]) {
163163 for idx , c := range result .columns {
164164 if c .NameValue .String == column {
165- c .UniqueValue = sql.NullBool {Bool : true , Valid : true }
165+ c .UniqueValue = sql.NullBool {Bool : strings . ToUpper ( strings . Fields ( str )[ 1 ]) == "UNIQUE" , Valid : true }
166166 result .columns [idx ] = c
167167 }
168168 }
Original file line number Diff line number Diff line change @@ -79,6 +79,24 @@ func TestParseDDL(t *testing.T) {
7979 },
8080 },
8181 },
82+ {
83+ "non-unique index" ,
84+ []string {
85+ "CREATE TABLE `test-c` (`field` integer NOT NULL)" ,
86+ "CREATE INDEX `idx_uq` ON `test-b`(`field`) WHERE field = 0" ,
87+ },
88+ 1 ,
89+ []migrator.ColumnType {
90+ {
91+ NameValue : sql.NullString {String : "field" , Valid : true },
92+ DataTypeValue : sql.NullString {String : "integer" , Valid : true },
93+ ColumnTypeValue : sql.NullString {String : "integer" , Valid : true },
94+ PrimaryKeyValue : sql.NullBool {Bool : false , Valid : true },
95+ UniqueValue : sql.NullBool {Bool : false , Valid : true },
96+ NullableValue : sql.NullBool {Bool : false , Valid : true },
97+ },
98+ },
99+ },
82100 }
83101
84102 for _ , p := range params {
You can’t perform that action at this time.
0 commit comments