You've already forked go-sqlmock
mirror of
https://github.com/DATA-DOG/go-sqlmock.git
synced 2025-06-14 23:55:00 +02:00
update and test query whitespace stripping
This commit is contained in:
16
util.go
16
util.go
@ -1,11 +1,17 @@
|
||||
package sqlmock
|
||||
|
||||
import "strings"
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var re *regexp.Regexp
|
||||
|
||||
func init() {
|
||||
re = regexp.MustCompile("\\s+")
|
||||
}
|
||||
|
||||
// strip out new lines and trim spaces
|
||||
func stripQuery(q string) (s string) {
|
||||
s = strings.Replace(q, "\n", " ", -1)
|
||||
s = strings.Replace(s, "\r", "", -1)
|
||||
s = strings.TrimSpace(s)
|
||||
return
|
||||
return strings.TrimSpace(re.ReplaceAllString(q, " "))
|
||||
}
|
||||
|
Reference in New Issue
Block a user