Skip to content

Commit

Permalink
squibble: clean SQL before diffing
Browse files Browse the repository at this point in the history
  • Loading branch information
creachadair committed Mar 19, 2024
1 parent 859b5cb commit f5bf154
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions squibble.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@ func SQLDigest(text string) (string, error) {
for i, r := range sr {
if r.Type == "table" {
sr[i].SQL = ""
} else {
sr[i].SQL = cleanSQL(sr[i].SQL)
}
}
h := sha256.New()
Expand All @@ -373,6 +375,8 @@ func DBDigest(ctx context.Context, db DBConn) (string, error) {
for i, r := range sr {
if r.Type == "table" {
sr[i].SQL = ""
} else {
sr[i].SQL = cleanSQL(sr[i].SQL)
}
}
h := sha256.New()
Expand Down
2 changes: 2 additions & 0 deletions textcrime.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,5 @@ func cleanLines(s string) []string {
}
return lines
}

func cleanSQL(s string) string { return strings.Join(cleanLines(s), " ") }

0 comments on commit f5bf154

Please sign in to comment.