Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions ddlmod.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,17 @@ func parseDDL(strs ...string) (*ddl, error) {
quote rune
buf string
)
ddlBodyRunesLen := len(ddlBodyRunes)

result.head = sections[1]

for idx := 0; idx < len(ddlBodyRunes); idx++ {
for idx := 0; idx < ddlBodyRunesLen; idx++ {
var (
next rune = 0
c = ddlBodyRunes[idx]
)
if idx+1 < len(ddlBody) {
next = []rune(ddlBody)[idx+1]
if idx+1 < ddlBodyRunesLen {
next = ddlBodyRunes[idx+1]
}

if sc := string(c); separatorRegexp.MatchString(sc) {
Expand Down
6 changes: 6 additions & 0 deletions ddlmod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ func TestParseDDL(t *testing.T) {
},
},
{"no brackets", []string{"create table test"}, 0, nil},
{"with_special_characters", []string{
"CREATE TABLE `test` (`text` varchar(10) DEFAULT \"测试,\")",
}, 1, []migrator.ColumnType{
{NameValue: sql.NullString{String: "text", Valid: true}, DataTypeValue: sql.NullString{String: "varchar(10)", Valid: true}, ColumnTypeValue: sql.NullString{String: "varchar(10)", Valid: true}, DefaultValueValue: sql.NullString{String: "测试,", Valid: true}, NullableValue: sql.NullBool{Valid: true}, UniqueValue: sql.NullBool{Valid: true}, PrimaryKeyValue: sql.NullBool{Valid: true}},
},
},
}

for _, p := range params {
Expand Down