From 67ed70c7ec678ec7a8b7282fa336e634edd3af2d Mon Sep 17 00:00:00 2001 From: Max Freedom Pollard <272618364+MaxFreedomPollard@users.noreply.github.com> Date: Thu, 22 Oct 2026 19:07:04 -0700 Subject: [PATCH] fix(bigquery): support escaped quotes in raw and bytes strings Fixes #762 Co-Authored-By: Claude Opus 5.5 --- src/languages/bigquery/bigquery.formatter.ts | 6 ++---- test/bigquery.test.ts | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/languages/bigquery/bigquery.formatter.ts b/src/languages/bigquery/bigquery.formatter.ts index 398951015a..cee581c3cc 100644 --- a/src/languages/bigquery/bigquery.formatter.ts +++ b/src/languages/bigquery/bigquery.formatter.ts @@ -179,10 +179,8 @@ export const bigquery: DialectOptions = { // Otherwise the first two quotes of """ will get matched as an empty "" string. { quote: '""".."""', prefixes: ['R', 'B', 'RB', 'BR'] }, { quote: "'''..'''", prefixes: ['R', 'B', 'RB', 'BR'] }, - '""-bs', - "''-bs", - { quote: '""-raw', prefixes: ['R', 'B', 'RB', 'BR'], requirePrefix: true }, - { quote: "''-raw", prefixes: ['R', 'B', 'RB', 'BR'], requirePrefix: true }, + { quote: '""-bs', prefixes: ['R', 'B', 'RB', 'BR'] }, + { quote: "''-bs", prefixes: ['R', 'B', 'RB', 'BR'] }, ], identTypes: ['``'], identChars: { dashes: true }, diff --git a/test/bigquery.test.ts b/test/bigquery.test.ts index d92e089b67..9bc21ce2c0 100644 --- a/test/bigquery.test.ts +++ b/test/bigquery.test.ts @@ -47,7 +47,7 @@ describe('BigQueryFormatter', () => { supportsUpdate(format); supportsTruncateTable(format); supportsMergeInto(format); - supportsStrings(format, ['""-bs', "''-bs", "R''", 'R""', "B''", 'B""']); + supportsStrings(format, ['""-bs', "''-bs", "B''", 'B""']); supportsIdentifiers(format, ['``']); supportsArrayLiterals(format, { withArrayPrefix: true, withoutArrayPrefix: true }); supportsBetween(format); @@ -166,6 +166,19 @@ describe('BigQueryFormatter', () => { `); }); + // Issue #762 + it('supports escaped quotes in strings with r, b and rb prefixes', () => { + expect(format(`SELECT r'a\\'b', R"c\\"d", b'e\\'f', rb"g\\"h" FROM foo`)).toBe(dedent` + SELECT + r'a\\'b', + R"c\\"d", + b'e\\'f', + rb"g\\"h" + FROM + foo + `); + }); + it('supports STRUCT types', () => { const result = format('SELECT STRUCT("Alpha" as name, [23.4, 26.3, 26.4] as splits) FROM beta'); expect(result).toBe(dedent`