Skip to content

Commit

Permalink
truncate colons at the end of queries
Browse files Browse the repository at this point in the history
  • Loading branch information
def committed Aug 7, 2023
1 parent 833e286 commit b8a372a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion obfuscate/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ func Sql(query string) string {
query = rePunctuation.ReplaceAllString(query, " $1 ")
query = reWhitespace.ReplaceAllString(query, " ")
query = strings.ReplaceAll(query, " ,", ",")
query = strings.Trim(query, " ")
query = strings.TrimLeft(query, " ")
query = strings.TrimRight(query, "; ")
return query
}

Expand Down
4 changes: 4 additions & 0 deletions obfuscate/sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ func TestSql(t *testing.T) {
in: "select lower('DdD'), cast(f as text)",
out: "select lower ( ? ), cast ( f as text )",
},
{
in: " select 1 ; ",
out: "select ?",
},
} {
assert.Equal(t, c.out, Sql(c.in), c.in)
}
Expand Down

0 comments on commit b8a372a

Please sign in to comment.