Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/languages/bigquery/bigquery.formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
15 changes: 14 additions & 1 deletion test/bigquery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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`
Expand Down
Loading