Skip to content

Commit bbd4b09

Browse files
committed
Test DuckDB TRUNCATE statement
1 parent 7477b8a commit bbd4b09

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

test/duckdb.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import supportsOnConflict from './features/onConflict.js';
2727
import supportsIsDistinctFrom from './features/isDistinctFrom.js';
2828
import supportsArrayLiterals from './features/arrayLiterals.js';
2929
import supportsDataTypeCase from './options/dataTypeCase.js';
30+
import supportsTruncateTable from './features/truncateTable.js';
3031

3132
describe('DuckDBFormatter', () => {
3233
const language = 'duckdb';
@@ -50,8 +51,7 @@ describe('DuckDBFormatter', () => {
5051
supportsInsertInto(format);
5152
supportsOnConflict(format);
5253
supportsUpdate(format);
53-
// TODO: only without-TABLE is supported
54-
// supportsTruncateTable(format, { withoutTable: true });
54+
supportsTruncateTable(format, { withTable: false, withoutTable: true });
5555
supportsStrings(format, ["''-qq", "X''", "B''"]);
5656
supportsIdentifiers(format, [`""-qq`]);
5757
supportsBetween(format);

test/features/truncateTable.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,22 @@ import dedent from 'dedent-js';
33
import { FormatFn } from '../../src/sqlFormatter.js';
44

55
interface TruncateTableConfig {
6+
withTable?: boolean;
67
withoutTable?: boolean;
78
}
89

910
export default function supportsTruncateTable(
1011
format: FormatFn,
11-
{ withoutTable }: TruncateTableConfig = {}
12+
{ withTable = true, withoutTable }: TruncateTableConfig = {}
1213
) {
13-
it('formats TRUNCATE TABLE statement', () => {
14-
const result = format('TRUNCATE TABLE Customers;');
15-
expect(result).toBe(dedent`
16-
TRUNCATE TABLE Customers;
17-
`);
18-
});
14+
if (withTable) {
15+
it('formats TRUNCATE TABLE statement', () => {
16+
const result = format('TRUNCATE TABLE Customers;');
17+
expect(result).toBe(dedent`
18+
TRUNCATE TABLE Customers;
19+
`);
20+
});
21+
}
1922

2023
if (withoutTable) {
2124
it('formats TRUNCATE statement (without TABLE)', () => {

0 commit comments

Comments
 (0)