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

This commit is contained in:
2024-03-09 14:59:32 +01:00
parent 9e5b8c5277
commit 42424f4bc2
9 changed files with 232 additions and 22 deletions

32
sq/commentTrimmer.go Normal file
View 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
}