-
Notifications
You must be signed in to change notification settings - Fork 283
/
Copy pathsqlite-query-compiler.ts
39 lines (30 loc) · 1.02 KB
/
sqlite-query-compiler.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { DefaultInsertValueNode } from '../../operation-node/default-insert-value-node.js'
import { DefaultQueryCompiler } from '../../query-compiler/default-query-compiler.js'
const ID_WRAP_REGEX = /"/g
export class SqliteQueryCompiler extends DefaultQueryCompiler {
protected override getCurrentParameterPlaceholder() {
return '?'
}
protected override getLeftExplainOptionsWrapper(): string {
return ''
}
protected override getRightExplainOptionsWrapper(): string {
return ''
}
protected override getLeftIdentifierWrapper(): string {
return '"'
}
protected override getRightIdentifierWrapper(): string {
return '"'
}
protected override getAutoIncrement() {
return 'autoincrement'
}
protected override sanitizeIdentifier(identifier: string): string {
return identifier.replace(ID_WRAP_REGEX, '""')
}
protected override visitDefaultInsertValue(_: DefaultInsertValueNode): void {
// sqlite doesn't support the `default` keyword in inserts.
this.append('null')
}
}