metal-orm 1.1.25 → 1.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1151 -510
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +281 -248
- package/dist/index.d.ts +281 -248
- package/dist/index.js +1133 -508
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/core/ddl/dialects/index.ts +5 -6
- package/src/core/ddl/dialects/mssql-schema-dialect.ts +129 -126
- package/src/core/ddl/dialects/mysql-schema-dialect.ts +119 -111
- package/src/core/ddl/dialects/postgres-schema-dialect.ts +173 -164
- package/src/core/ddl/dialects/render-reference.test.ts +37 -57
- package/src/core/ddl/dialects/sqlite-schema-dialect.ts +110 -121
- package/src/core/ddl/schema-dialect-composer.ts +129 -0
- package/src/core/ddl/schema-dialect.ts +40 -27
- package/src/core/ddl/schema-diff.ts +119 -90
- package/src/core/dialect/abstract.ts +7 -229
- package/src/core/dialect/base/sql-dialect-composer.ts +294 -0
- package/src/core/dialect/base/standard-sql-services.ts +2 -6
- package/src/core/dialect/base/upsert-strategy.ts +1 -2
- package/src/core/dialect/dialect-factory.ts +17 -49
- package/src/core/dialect/mssql/index.ts +56 -27
- package/src/core/dialect/mysql/index.ts +69 -36
- package/src/core/dialect/postgres/index.ts +71 -43
- package/src/core/dialect/sqlite/index.ts +68 -38
- package/src/core/driver/mssql-driver.ts +6 -8
- package/src/core/driver/mysql-driver.ts +6 -8
- package/src/core/driver/postgres-driver.ts +6 -8
- package/src/core/driver/sqlite-driver.ts +6 -8
- package/src/index.ts +13 -1
- package/src/core/ddl/dialects/base-schema-dialect.ts +0 -96
- package/src/core/dialect/base/sql-dialect.ts +0 -217
|
@@ -1,68 +1,96 @@
|
|
|
1
1
|
import type { ProcedureCallNode } from '../../ast/procedure.js';
|
|
2
2
|
import type { BitwiseExpressionNode, ColumnNode, JsonPathNode } from '../../ast/expression.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
DeleteQueryNode,
|
|
5
|
+
InsertQueryNode,
|
|
6
|
+
SelectQueryNode,
|
|
7
|
+
TableNode,
|
|
8
|
+
UpdateQueryNode
|
|
9
|
+
} from '../../ast/query.js';
|
|
10
|
+
import type { CompiledQuery, Dialect } from '../abstract.js';
|
|
4
11
|
import type { CompiledProcedureCall, ProcedureCompiler } from '../capabilities/procedure-compiler.js';
|
|
5
|
-
import {
|
|
12
|
+
import { composeSqlDialect } from '../base/sql-dialect-composer.js';
|
|
6
13
|
import { PostgresFunctionStrategy } from './functions.js';
|
|
7
14
|
import { PostgresTableFunctionStrategy } from './table-functions.js';
|
|
8
15
|
import { PostgresProcedureCompiler } from './procedure-compiler.js';
|
|
9
16
|
import { PostgresReturningStrategy } from './returning.js';
|
|
10
17
|
import { PostgresUpsertStrategy } from './upsert.js';
|
|
11
18
|
|
|
12
|
-
|
|
13
|
-
export class PostgresDialect extends SqlDialectBase implements ProcedureCompiler {
|
|
14
|
-
protected readonly dialect = 'postgres';
|
|
15
|
-
private readonly procedureCompiler: PostgresProcedureCompiler;
|
|
19
|
+
const quoteIdentifier = (id: string): string => `"${id}"`;
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
super({
|
|
19
|
-
functionStrategy: new PostgresFunctionStrategy(),
|
|
20
|
-
tableFunctionStrategy: new PostgresTableFunctionStrategy(),
|
|
21
|
-
returningStrategy: new PostgresReturningStrategy(),
|
|
22
|
-
upsertStrategy: new PostgresUpsertStrategy(),
|
|
23
|
-
supportsDmlReturning: true
|
|
24
|
-
});
|
|
21
|
+
export type PostgresDialectImplementation = Dialect & ProcedureCompiler;
|
|
25
22
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
/** Creates the PostgreSQL dialect entirely from composable compiler components. */
|
|
24
|
+
export const createPostgresDialect = (): PostgresDialectImplementation => {
|
|
25
|
+
const composition = composeSqlDialect({
|
|
26
|
+
name: 'postgres',
|
|
27
|
+
quoteIdentifier,
|
|
28
|
+
formatPlaceholder: index => `$${index}`,
|
|
29
|
+
functionStrategy: new PostgresFunctionStrategy(),
|
|
30
|
+
tableFunctionStrategy: new PostgresTableFunctionStrategy(),
|
|
31
|
+
returningStrategy: new PostgresReturningStrategy(),
|
|
32
|
+
upsertStrategy: new PostgresUpsertStrategy(),
|
|
33
|
+
supportsDmlReturning: true,
|
|
34
|
+
compileSetTarget: (column: ColumnNode, _table: TableNode) => {
|
|
35
|
+
void _table;
|
|
36
|
+
return quoteIdentifier(column.name);
|
|
37
|
+
},
|
|
38
|
+
compileJsonPath(node: JsonPathNode): string {
|
|
39
|
+
const column = `${quoteIdentifier(node.column.table)}.${quoteIdentifier(node.column.name)}`;
|
|
40
|
+
return `${column}->>'${node.path}'`;
|
|
41
|
+
},
|
|
42
|
+
configureExpressions(api) {
|
|
43
|
+
api.registerExpressionCompiler('BitwiseExpression', (node: BitwiseExpressionNode, ctx) => {
|
|
44
|
+
const left = api.compileOperand(node.left, ctx);
|
|
45
|
+
const right = api.compileOperand(node.right, ctx);
|
|
46
|
+
const operator = node.operator === '^' ? '#' : node.operator;
|
|
47
|
+
return `${left} ${operator} ${right}`;
|
|
48
|
+
});
|
|
49
|
+
api.registerOperandCompiler('BitwiseExpression', (node: BitwiseExpressionNode, ctx) => {
|
|
50
|
+
const left = api.compileOperand(node.left, ctx);
|
|
51
|
+
const right = api.compileOperand(node.right, ctx);
|
|
52
|
+
const operator = node.operator === '^' ? '#' : node.operator;
|
|
53
|
+
return `(${left} ${operator} ${right})`;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
31
57
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return `(${left} ${operator} ${right})`;
|
|
43
|
-
});
|
|
44
|
-
}
|
|
58
|
+
const procedures = new PostgresProcedureCompiler(composition.runtime);
|
|
59
|
+
return {
|
|
60
|
+
...composition.dialect,
|
|
61
|
+
compileProcedureCall: ast => procedures.compileProcedureCall(ast)
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/** Ergonomic constructor facade over the composed PostgreSQL dialect. */
|
|
66
|
+
export class PostgresDialect implements Dialect, ProcedureCompiler {
|
|
67
|
+
private readonly impl: PostgresDialectImplementation = createPostgresDialect();
|
|
45
68
|
|
|
46
69
|
quoteIdentifier(id: string): string {
|
|
47
|
-
return
|
|
70
|
+
return this.impl.quoteIdentifier(id);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
supportsDmlReturningClause(): boolean {
|
|
74
|
+
return this.impl.supportsDmlReturningClause();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
compileSelect(ast: SelectQueryNode): CompiledQuery {
|
|
78
|
+
return this.impl.compileSelect(ast);
|
|
48
79
|
}
|
|
49
80
|
|
|
50
|
-
|
|
51
|
-
return
|
|
81
|
+
compileInsert(ast: InsertQueryNode): CompiledQuery {
|
|
82
|
+
return this.impl.compileInsert(ast);
|
|
52
83
|
}
|
|
53
84
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return `${column}->>'${node.path}'`;
|
|
85
|
+
compileUpdate(ast: UpdateQueryNode): CompiledQuery {
|
|
86
|
+
return this.impl.compileUpdate(ast);
|
|
57
87
|
}
|
|
58
88
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
void _table;
|
|
62
|
-
return this.quoteIdentifier(column.name);
|
|
89
|
+
compileDelete(ast: DeleteQueryNode): CompiledQuery {
|
|
90
|
+
return this.impl.compileDelete(ast);
|
|
63
91
|
}
|
|
64
92
|
|
|
65
93
|
compileProcedureCall(ast: ProcedureCallNode): CompiledProcedureCall {
|
|
66
|
-
return this.
|
|
94
|
+
return this.impl.compileProcedureCall(ast);
|
|
67
95
|
}
|
|
68
96
|
}
|
|
@@ -1,51 +1,81 @@
|
|
|
1
1
|
import type { BitwiseExpressionNode, ColumnNode, JsonPathNode } from '../../ast/expression.js';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type {
|
|
3
|
+
DeleteQueryNode,
|
|
4
|
+
InsertQueryNode,
|
|
5
|
+
SelectQueryNode,
|
|
6
|
+
TableNode,
|
|
7
|
+
UpdateQueryNode
|
|
8
|
+
} from '../../ast/query.js';
|
|
9
|
+
import type { CompiledQuery, Dialect } from '../abstract.js';
|
|
10
|
+
import { composeSqlDialect } from '../base/sql-dialect-composer.js';
|
|
4
11
|
import { SqliteFunctionStrategy } from './functions.js';
|
|
5
12
|
import { SqliteReturningStrategy } from './returning.js';
|
|
6
13
|
import { SqliteUpsertStrategy } from './upsert.js';
|
|
7
14
|
|
|
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
|
-
|
|
15
|
+
const quoteIdentifier = (id: string): string => `"${id}"`;
|
|
16
|
+
|
|
17
|
+
/** Creates the SQLite dialect entirely from composable compiler components. */
|
|
18
|
+
export const createSqliteDialect = (): Dialect =>
|
|
19
|
+
composeSqlDialect({
|
|
20
|
+
name: 'sqlite',
|
|
21
|
+
quoteIdentifier,
|
|
22
|
+
functionStrategy: new SqliteFunctionStrategy(),
|
|
23
|
+
returningStrategy: new SqliteReturningStrategy(),
|
|
24
|
+
upsertStrategy: new SqliteUpsertStrategy(),
|
|
25
|
+
supportsDmlReturning: true,
|
|
26
|
+
compileSetTarget: (column: ColumnNode, _table: TableNode) => {
|
|
27
|
+
void _table;
|
|
28
|
+
return quoteIdentifier(column.name);
|
|
29
|
+
},
|
|
30
|
+
compileJsonPath(node: JsonPathNode): string {
|
|
31
|
+
const column = `${quoteIdentifier(node.column.table)}.${quoteIdentifier(node.column.name)}`;
|
|
32
|
+
return `json_extract(${column}, '${node.path}')`;
|
|
33
|
+
},
|
|
34
|
+
configureExpressions(api) {
|
|
35
|
+
api.registerExpressionCompiler('BitwiseExpression', (node: BitwiseExpressionNode, ctx) => {
|
|
36
|
+
const left = api.compileOperand(node.left, ctx);
|
|
37
|
+
const right = api.compileOperand(node.right, ctx);
|
|
38
|
+
if (node.operator === '^') {
|
|
39
|
+
return `(${left} | ${right}) & ~(${left} & ${right})`;
|
|
40
|
+
}
|
|
41
|
+
return `${left} ${node.operator} ${right}`;
|
|
42
|
+
});
|
|
43
|
+
api.registerOperandCompiler('BitwiseExpression', (node: BitwiseExpressionNode, ctx) => {
|
|
44
|
+
const left = api.compileOperand(node.left, ctx);
|
|
45
|
+
const right = api.compileOperand(node.right, ctx);
|
|
46
|
+
if (node.operator === '^') {
|
|
47
|
+
return `((${left} | ${right}) & ~(${left} & ${right}))`;
|
|
48
|
+
}
|
|
49
|
+
return `(${left} ${node.operator} ${right})`;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}).dialect;
|
|
53
|
+
|
|
54
|
+
/** Ergonomic constructor facade over the composed SQLite dialect. */
|
|
55
|
+
export class SqliteDialect implements Dialect {
|
|
56
|
+
private readonly impl: Dialect = createSqliteDialect();
|
|
37
57
|
|
|
38
58
|
quoteIdentifier(id: string): string {
|
|
39
|
-
return
|
|
59
|
+
return this.impl.quoteIdentifier(id);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
supportsDmlReturningClause(): boolean {
|
|
63
|
+
return this.impl.supportsDmlReturningClause();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
compileSelect(ast: SelectQueryNode): CompiledQuery {
|
|
67
|
+
return this.impl.compileSelect(ast);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
compileInsert(ast: InsertQueryNode): CompiledQuery {
|
|
71
|
+
return this.impl.compileInsert(ast);
|
|
40
72
|
}
|
|
41
73
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return `json_extract(${column}, '${node.path}')`;
|
|
74
|
+
compileUpdate(ast: UpdateQueryNode): CompiledQuery {
|
|
75
|
+
return this.impl.compileUpdate(ast);
|
|
45
76
|
}
|
|
46
77
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return this.quoteIdentifier(column.name);
|
|
78
|
+
compileDelete(ast: DeleteQueryNode): CompiledQuery {
|
|
79
|
+
return this.impl.compileDelete(ast);
|
|
50
80
|
}
|
|
51
81
|
}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import { DatabaseDriver } from './database-driver.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { DatabaseDriver } from './database-driver.js';
|
|
2
|
+
import { createSqlServerDialect } from '../dialect/mssql/index.js';
|
|
3
|
+
import { createMssqlSchemaDialect } from '../ddl/dialects/mssql-schema-dialect.js';
|
|
4
4
|
import { mssqlIntrospector } from '../ddl/introspect/mssql.js';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Database driver for Microsoft SQL Server.
|
|
8
|
-
*/
|
|
6
|
+
/** Database driver for Microsoft SQL Server. */
|
|
9
7
|
export class MssqlDriver implements DatabaseDriver {
|
|
10
8
|
readonly name = 'mssql';
|
|
11
9
|
|
|
12
10
|
createDialect() {
|
|
13
|
-
return
|
|
11
|
+
return createSqlServerDialect();
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
createSchemaDialect() {
|
|
17
|
-
return
|
|
15
|
+
return createMssqlSchemaDialect();
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
createIntrospector() {
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import { DatabaseDriver } from './database-driver.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { DatabaseDriver } from './database-driver.js';
|
|
2
|
+
import { createMySqlDialect } from '../dialect/mysql/index.js';
|
|
3
|
+
import { createMySqlSchemaDialect } from '../ddl/dialects/mysql-schema-dialect.js';
|
|
4
4
|
import { mysqlIntrospector } from '../ddl/introspect/mysql.js';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Database driver for MySQL.
|
|
8
|
-
*/
|
|
6
|
+
/** Database driver for MySQL. */
|
|
9
7
|
export class MySqlDriver implements DatabaseDriver {
|
|
10
8
|
readonly name = 'mysql';
|
|
11
9
|
|
|
12
10
|
createDialect() {
|
|
13
|
-
return
|
|
11
|
+
return createMySqlDialect();
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
createSchemaDialect() {
|
|
17
|
-
return
|
|
15
|
+
return createMySqlSchemaDialect();
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
createIntrospector() {
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import { DatabaseDriver } from './database-driver.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { DatabaseDriver } from './database-driver.js';
|
|
2
|
+
import { createPostgresDialect } from '../dialect/postgres/index.js';
|
|
3
|
+
import { createPostgresSchemaDialect } from '../ddl/dialects/postgres-schema-dialect.js';
|
|
4
4
|
import { postgresIntrospector } from '../ddl/introspect/postgres.js';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Database driver for PostgreSQL.
|
|
8
|
-
*/
|
|
6
|
+
/** Database driver for PostgreSQL. */
|
|
9
7
|
export class PostgresDriver implements DatabaseDriver {
|
|
10
8
|
readonly name = 'postgres';
|
|
11
9
|
|
|
12
10
|
createDialect() {
|
|
13
|
-
return
|
|
11
|
+
return createPostgresDialect();
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
createSchemaDialect() {
|
|
17
|
-
return
|
|
15
|
+
return createPostgresSchemaDialect();
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
createIntrospector() {
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import { DatabaseDriver } from './database-driver.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { DatabaseDriver } from './database-driver.js';
|
|
2
|
+
import { createSqliteDialect } from '../dialect/sqlite/index.js';
|
|
3
|
+
import { createSqliteSchemaDialect } from '../ddl/dialects/sqlite-schema-dialect.js';
|
|
4
4
|
import { sqliteIntrospector } from '../ddl/introspect/sqlite.js';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Database driver for SQLite.
|
|
8
|
-
*/
|
|
6
|
+
/** Database driver for SQLite. */
|
|
9
7
|
export class SqliteDriver implements DatabaseDriver {
|
|
10
8
|
readonly name = 'sqlite';
|
|
11
9
|
|
|
12
10
|
createDialect() {
|
|
13
|
-
return
|
|
11
|
+
return createSqliteDialect();
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
createSchemaDialect() {
|
|
17
|
-
return
|
|
15
|
+
return createSqliteSchemaDialect();
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
createIntrospector() {
|
package/src/index.ts
CHANGED
|
@@ -20,7 +20,7 @@ export * from './core/hydration/types.js';
|
|
|
20
20
|
export * from './core/dialect/abstract.js';
|
|
21
21
|
export * from './core/dialect/dialect-factory.js';
|
|
22
22
|
export * from './core/dialect/capabilities/procedure-compiler.js';
|
|
23
|
-
export * from './core/dialect/base/sql-dialect.js';
|
|
23
|
+
export * from './core/dialect/base/sql-dialect-composer.js';
|
|
24
24
|
export * from './core/dialect/base/sql-compiler-set.js';
|
|
25
25
|
export * from './core/dialect/base/upsert-strategy.js';
|
|
26
26
|
export * from './core/dialect/base/returning-strategy.js';
|
|
@@ -55,6 +55,18 @@ export * from './core/ddl/schema-generator.js';
|
|
|
55
55
|
export * from './core/ddl/schema-types.js';
|
|
56
56
|
export * from './core/ddl/schema-diff.js';
|
|
57
57
|
export * from './core/ddl/schema-introspect.js';
|
|
58
|
+
export * from './core/ddl/schema-dialect-composer.js';
|
|
59
|
+
export * from './core/ddl/dialects/index.js';
|
|
60
|
+
export { createLiteralFormatter } from './core/ddl/sql-writing.js';
|
|
61
|
+
export type { LiteralFormatter, LiteralFormatOptions } from './core/ddl/sql-writing.js';
|
|
62
|
+
export type {
|
|
63
|
+
SchemaDialect,
|
|
64
|
+
SchemaMutationCapabilities,
|
|
65
|
+
DropTableCapability,
|
|
66
|
+
DropColumnCapability,
|
|
67
|
+
DropIndexCapability,
|
|
68
|
+
AlterColumnCapability
|
|
69
|
+
} from './core/ddl/schema-dialect.js';
|
|
58
70
|
export * from './core/ddl/introspect/registry.js';
|
|
59
71
|
export * from './core/functions/text.js';
|
|
60
72
|
export * from './core/functions/numeric.js';
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { SchemaDialect, DialectName } from '../schema-dialect.js';
|
|
2
|
-
import { formatLiteral, quoteQualified, LiteralFormatter } from '../sql-writing.js';
|
|
3
|
-
import { ColumnDef, ForeignKeyReference } from '../../../schema/column-types.js';
|
|
4
|
-
import { IndexDef, TableDef } from '../../../schema/table.js';
|
|
5
|
-
import { DatabaseTable, DatabaseColumn, ColumnDiff } from '../schema-types.js';
|
|
6
|
-
|
|
7
|
-
/** A table-like object with name and optional schema. */
|
|
8
|
-
type TableLike = { name: string; schema?: string };
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Common behavior for schema dialects (DDL).
|
|
12
|
-
* Concrete dialects only override the small surface area instead of reimplementing everything.
|
|
13
|
-
*/
|
|
14
|
-
export abstract class BaseSchemaDialect implements SchemaDialect {
|
|
15
|
-
/** The name of the dialect. */
|
|
16
|
-
abstract readonly name: DialectName;
|
|
17
|
-
/** Quotes an identifier for use in SQL. */
|
|
18
|
-
abstract quoteIdentifier(id: string): string;
|
|
19
|
-
/** Renders the column type for SQL. */
|
|
20
|
-
abstract renderColumnType(column: ColumnDef): string;
|
|
21
|
-
/** Renders the auto-increment clause for SQL. */
|
|
22
|
-
abstract renderAutoIncrement(column: ColumnDef, table: TableDef): string | undefined;
|
|
23
|
-
/** Renders an index for SQL. */
|
|
24
|
-
abstract renderIndex(table: TableDef, index: IndexDef): string;
|
|
25
|
-
supportsPartialIndexes(): boolean {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
formatTableName(table: TableLike): string {
|
|
29
|
-
if (table.schema) {
|
|
30
|
-
return `${this.quoteIdentifier(table.schema)}.${this.quoteIdentifier(table.name)}`;
|
|
31
|
-
}
|
|
32
|
-
return this.quoteIdentifier(table.name);
|
|
33
|
-
}
|
|
34
|
-
/** The literal formatter for the dialect. */
|
|
35
|
-
abstract get literalFormatter(): LiteralFormatter;
|
|
36
|
-
|
|
37
|
-
renderDefault(value: unknown, _column: ColumnDef): string {
|
|
38
|
-
void _column;
|
|
39
|
-
return formatLiteral(this.literalFormatter, value);
|
|
40
|
-
}
|
|
41
|
-
renderReference(ref: ForeignKeyReference, _table: TableDef): string {
|
|
42
|
-
void _table;
|
|
43
|
-
const parts = ['REFERENCES', quoteQualified(this, ref.table), `(${this.quoteIdentifier(ref.column)})`];
|
|
44
|
-
if (ref.onDelete) parts.push('ON DELETE', ref.onDelete);
|
|
45
|
-
if (ref.onUpdate) parts.push('ON UPDATE', ref.onUpdate);
|
|
46
|
-
const suffix = this.renderReferenceSuffix(ref, _table);
|
|
47
|
-
if (suffix) parts.push(suffix);
|
|
48
|
-
return parts.join(' ');
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
protected renderReferenceSuffix(ref: ForeignKeyReference, _table: TableDef): string | undefined {
|
|
52
|
-
void ref;
|
|
53
|
-
void _table;
|
|
54
|
-
return undefined;
|
|
55
|
-
}
|
|
56
|
-
renderTableOptions(_table: TableDef): string | undefined {
|
|
57
|
-
void _table;
|
|
58
|
-
return undefined;
|
|
59
|
-
}
|
|
60
|
-
dropTableSql(table: DatabaseTable): string[] {
|
|
61
|
-
return [`DROP TABLE IF EXISTS ${this.formatTableName(table)};`];
|
|
62
|
-
}
|
|
63
|
-
dropColumnSql(table: DatabaseTable, column: string): string[] {
|
|
64
|
-
return [`ALTER TABLE ${this.formatTableName(table)} DROP COLUMN ${this.quoteIdentifier(column)};`];
|
|
65
|
-
}
|
|
66
|
-
dropIndexSql(table: DatabaseTable, index: string): string[] {
|
|
67
|
-
return [`DROP INDEX ${this.quoteIdentifier(index)};`];
|
|
68
|
-
}
|
|
69
|
-
warnDropColumn(_table: DatabaseTable, _column: string): string | undefined {
|
|
70
|
-
void _table;
|
|
71
|
-
void _column;
|
|
72
|
-
return undefined;
|
|
73
|
-
}
|
|
74
|
-
alterColumnSql?(_table: TableDef, _column: ColumnDef, _actualColumn: DatabaseColumn, _diff: ColumnDiff): string[] {
|
|
75
|
-
void _table;
|
|
76
|
-
void _column;
|
|
77
|
-
void _actualColumn;
|
|
78
|
-
void _diff;
|
|
79
|
-
return [];
|
|
80
|
-
}
|
|
81
|
-
warnAlterColumn?(_table: TableDef, _column: ColumnDef, _actual: DatabaseColumn, _diff: ColumnDiff): string | undefined {
|
|
82
|
-
void _table;
|
|
83
|
-
void _column;
|
|
84
|
-
void _actual;
|
|
85
|
-
void _diff;
|
|
86
|
-
return undefined;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
preferInlinePkAutoincrement(_column: ColumnDef, _table: TableDef, _pk: string[]): boolean {
|
|
90
|
-
void _column;
|
|
91
|
-
void _table;
|
|
92
|
-
void _pk;
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|