v0.0.400 added CommentTrimmer and DBOptions to sq
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 2m16s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 2m16s
This commit is contained in:
32
sq/commentTrimmer.go
Normal file
32
sq/commentTrimmer.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package sq
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var CommentTrimmer = NewPreListener(fnTrimComments)
|
||||
|
||||
func fnTrimComments(ctx context.Context, cmdtype string, id *uint16, sql *string, params *PP) error {
|
||||
|
||||
res := make([]string, 0)
|
||||
|
||||
for _, s := range strings.Split(*sql, "\n") {
|
||||
if strings.HasPrefix(strings.TrimSpace(s), "--") {
|
||||
continue
|
||||
}
|
||||
|
||||
idx := strings.Index(s, "--")
|
||||
if idx != -1 {
|
||||
s = s[:idx]
|
||||
}
|
||||
|
||||
s = strings.TrimRight(s, " \t\r\n")
|
||||
|
||||
res = append(res, s)
|
||||
}
|
||||
|
||||
*sql = strings.Join(res, "\n")
|
||||
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user