Skip to content

Commit ebcdf89

Browse files
committed
Allow ODBC date format. Closes #877
1 parent efee49f commit ebcdf89

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/languages/transactsql/transactsql.formatter.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,10 @@ export const transactsql: DialectOptions = {
246246
reservedDataTypes: dataTypes,
247247
reservedFunctionNames: functions,
248248
nestedBlockComments: true,
249-
stringTypes: [{ quote: "''-qq", prefixes: ['N'] }],
249+
stringTypes: [
250+
{ quote: "''-qq", prefixes: ['N'] },
251+
'{}'
252+
],
250253
identTypes: [`""-qq`, '[]'],
251254
identChars: { first: '#@', rest: '#@$' },
252255
paramTypes: { named: ['@'], quoted: ['@'] },

test/transactsql.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,22 @@ describe('TransactSqlFormatter', () => {
227227
Zone
228228
`);
229229
});
230+
231+
// Issue #877
232+
it('allows the use of the ODBC date format', () => {
233+
const result = format(
234+
`WITH [sales_query] AS (SELECT [customerId] FROM [segments].dbo.[sales] WHERE [salesdate] > {d'2024-01-01'})`
235+
);
236+
expect(result).toBe(dedent`
237+
WITH
238+
[sales_query] AS (
239+
SELECT
240+
[customerId]
241+
FROM
242+
[segments].dbo.[sales]
243+
WHERE
244+
[salesdate] > {d'2024-01-01'}
245+
)
246+
`);
247+
});
230248
});

0 commit comments

Comments
 (0)