Skip to content

Commit fcc0289

Browse files
author
Georg Traar
committed
change drop to check if table exists
1 parent 72c2c4a commit fcc0289

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/StatementGenerator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class StatementGenerator {
6060
}
6161

6262
public static dropTable(tableName: string): string {
63-
return `DROP TABLE ${this.quoteIdentifier(tableName)};`;
63+
return `DROP TABLE IF EXISTS ${this.quoteIdentifier(tableName)};`;
6464
}
6565

6666
public static insert(tableName: string, keys: string[], primaryKeys: string[] | null): string {

tests/StatementGenerator.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ describe('StatementGenerator SQL Generation', () => {
106106
// Maintenance commands (DROP, REFRESH)
107107
it('should generate a DROP TABLE query', () => {
108108
const tableName = 'my_table';
109-
expect(StatementGenerator.dropTable(tableName)).toBe(`DROP TABLE "my_table";`);
109+
expect(StatementGenerator.dropTable(tableName)).toBe(`DROP TABLE IF EXISTS "my_table";`);
110110
});
111111

112112
it('should generate a REFRESH query', () => {

0 commit comments

Comments
 (0)