Skip to content

Commit f346d6e

Browse files
committed
add semicolon to sql statements fix #103
1 parent 30d28e4 commit f346d6e

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

cmd/queryx/action/db.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"fmt"
66
"os"
77
"path/filepath"
8-
"strings"
98
"time"
109

1110
"ariga.io/atlas/sql/migrate"
@@ -170,6 +169,14 @@ func createFile(f string, content string) error {
170169
return nil
171170
}
172171

172+
func createSQL(stats []string) string {
173+
var sql string
174+
for _, stat := range stats {
175+
sql += stat + ";\n" // TODO: support windows line break
176+
}
177+
return sql
178+
}
179+
173180
func dbMigrateGenerate() error {
174181
sch, err := newSchema()
175182
if err != nil {
@@ -201,7 +208,7 @@ func dbMigrateGenerate() error {
201208
downs := []string{}
202209
for _, change := range changes {
203210
if change.Cmd != "" {
204-
ups = append(ups, change.Cmd+";")
211+
ups = append(ups, change.Cmd)
205212
}
206213

207214
stmts, err := change.ReverseStmts()
@@ -210,9 +217,8 @@ func dbMigrateGenerate() error {
210217
}
211218
downs = append(stmts, downs...)
212219
}
213-
// TODO: support windows line break
214-
up := strings.Join(ups, "\n")
215-
down := strings.Join(downs, "\n")
220+
up := createSQL(ups)
221+
down := createSQL(downs)
216222

217223
// TODO: support migration name
218224
name := "auto"

0 commit comments

Comments
 (0)