@@ -109,7 +109,7 @@ parse:
109109 i , ok = readMultilineComment (b .raw , i , b .rawlen )
110110 b .comment = ! ok
111111 // start of a string
112- case c == '\'' || c == '"' :
112+ case c == '\'' || c == '"' || c == '[' :
113113 b .quote = c
114114 // inline sql comment, skip to end of line
115115 case c == '-' && next == '-' :
@@ -145,25 +145,24 @@ parse:
145145 }
146146 }
147147 if err == nil {
148- i = min (i , b .rawlen )
149- empty := isEmptyLine (b .raw , 0 , i )
150- appendLine := true
151- if ! b .comment && command != nil && empty {
152- appendLine = false
153- }
154- if appendLine {
155- // any variables on the line need to be added to the global map
156- inc := 0
157- if b .Length > 0 {
158- inc = len (lineend )
159- }
160- if b .linevarmap != nil {
161- for v := range b .linevarmap {
162- b .varmap [v + b .Length + inc ] = b .linevarmap [v ]
148+ if command == nil {
149+ i = min (i , b .rawlen )
150+ empty := i == 0
151+ appendLine := ! empty || b .comment || b .quote != 0
152+ if appendLine {
153+ // any variables on the line need to be added to the global map
154+ inc := 0
155+ if b .Length > 0 {
156+ inc = len (lineend )
157+ }
158+ if b .linevarmap != nil {
159+ for v := range b .linevarmap {
160+ b .varmap [v + b .Length + inc ] = b .linevarmap [v ]
161+ }
163162 }
163+ // log.Printf(">> appending: `%s`", string(r[st:i]))
164+ b .append (b .raw [:i ], lineend )
164165 }
165- // log.Printf(">> appending: `%s`", string(r[st:i]))
166- b .append (b .raw [:i ], lineend )
167166 b .batchline ++
168167 }
169168 b .raw = b .raw [i :]
@@ -242,11 +241,13 @@ func (b *Batch) readString(r []rune, i, end int, quote rune, line uint) (int, bo
242241 } else {
243242 return i , false , syntaxError (line )
244243 }
245- case quote == '\'' && c == '\'' && next == '\'' :
244+ case quote == '\'' && c == '\'' && next == '\'' ,
245+ quote == '[' && c == ']' && next == ']' :
246246 i ++
247247 continue
248248 case quote == '\'' && c == '\'' && prev != '\'' ,
249- quote == '"' && c == '"' :
249+ quote == '"' && c == '"' ,
250+ quote == '[' && c == ']' :
250251 return i , true , nil
251252 }
252253 prev = c
0 commit comments