diff --git a/query/query.go b/query/query.go index 3a6ca57..fb44f98 100644 --- a/query/query.go +++ b/query/query.go @@ -541,8 +541,8 @@ func Fingerprint(q string) string { // so advance cpFromOffset to whatever is after the space // and if it's more space then space skipping block will // handle it. - cpFromOffset = qi + 1 } + cpFromOffset = qi + 1 } else if s == inDash { if Debug { fmt.Println("One-line comment begin") diff --git a/query/query_test.go b/query/query_test.go index 03949bc..0b3a433 100644 --- a/query/query_test.go +++ b/query/query_test.go @@ -650,3 +650,22 @@ func TestFingerprintWithNumberInDbName(t *testing.T) { query.Fingerprint(q), ) } + +func TestFingerprintMaxExecTimeWithBackticks(t *testing.T) { + q := "/* test-test-5775b87c5d-fczwg|@test-test|test-test|internal|/internal/test|test-test */\n\n SELECT /*+ MAX_EXECUTION_TIME(7995) */ `id`, `domain`, `city_id`, `name`, `polygon`, `state`, `translations` AS `translations`\n FROM `area`\n WHERE `state` IN ('active', 'disabled', 'removed') AND `domain` = 'test'" + + assert.Equal( + t, + "select `id`, `domain`, `city_id`, `name`, `polygon`, `state`, `translations` as `translations` from `area` where `state` in(?+) and `domain` = ?", + query.Fingerprint(q), + ) +} + +func TestFingerprintMaxExecTimeNoBackticks(t *testing.T) { + q := "/* test-test-5775b87c5d-fczwg|@test-test|test-test|internal|/internal/test|test-test */\n\n SELECT /*+ MAX_EXECUTION_TIME(7995) */ id, domain, city_id, name, polygon, state, translations AS translations\n FROM area\n WHERE state IN ('active', 'disabled', 'removed') AND domain = 'test'" + + assert.Equal(t, + "select id, domain, city_id, name, polygon, state, translations as translations from area where state in(?+) and domain = ?", + query.Fingerprint(q), + ) +}