Only run actual query without any comments

This commit is contained in:
Dan Sosedoff
2016-02-18 22:18:07 -06:00
parent 540613645f
commit 6edc384c05
3 changed files with 25 additions and 5 deletions

View File

@@ -45,6 +45,21 @@ func NewError(err error) Error {
return Error{err.Error()}
}
// Returns a clean query without any comment statements
func cleanQuery(query string) string {
lines := []string{}
for _, line := range strings.Split(query, "\n") {
line = strings.TrimSpace(line)
if strings.HasPrefix(line, "--") {
continue
}
lines = append(lines, line)
}
return strings.TrimSpace(strings.Join(lines, "\n"))
}
func desanitize64(query string) string {
// Before feeding the string into decoded, we must "reconstruct" the base64 data.
// Javascript replaces a few characters to be url-safe.