Skip to content

Commit 8d54079

Browse files
committed
fix: fall back to origin SQL when failing
1 parent 8eb3c31 commit 8d54079

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

fingerprint.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ package qshape
33
import pg_query "github.com/pganalyze/pg_query_go/v6"
44

55
func Fingerprint(sql string) (string, error) {
6-
// Normalize first so ORM variants share a fingerprint
7-
canonical, err := Normalize(sql)
8-
if err != nil {
9-
return "", err
6+
// Normalize first so ORM variants share a fingerprint; fall back to raw
7+
// SQL when normalization hits a deparse gap so we still return a fingerprint
8+
target := sql
9+
if canonical, err := Normalize(sql); err == nil {
10+
target = canonical
1011
}
11-
fp, err := pg_query.Fingerprint(canonical)
12+
fp, err := pg_query.Fingerprint(target)
1213
if err != nil {
1314
return "", err
1415
}

0 commit comments

Comments
 (0)