@mikro-orm/mssql 7.2.6-dev.13 → 7.2.6-dev.16
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/MsSqlSchemaHelper.d.ts +0 -1
- package/MsSqlSchemaHelper.js +17 -19
- package/package.json +3 -3
package/MsSqlSchemaHelper.d.ts
CHANGED
|
@@ -20,7 +20,6 @@ export declare class MsSqlSchemaHelper extends SchemaHelper {
|
|
|
20
20
|
normalizeDefaultValue(defaultValue: string, length: number, defaultValues?: Dictionary<string[]>, stripQuotes?: boolean): string | number;
|
|
21
21
|
getAllColumns(connection: AbstractSqlConnection, tablesBySchemas: Map<string | undefined, Table[]>, ctx?: Transaction): Promise<Dictionary<Column[]>>;
|
|
22
22
|
getAllIndexes(connection: AbstractSqlConnection, tablesBySchemas: Map<string | undefined, Table[]>, ctx?: Transaction): Promise<Dictionary<IndexDef[]>>;
|
|
23
|
-
mapForeignKeys(fks: any[], tableName: string, schemaName?: string): Dictionary;
|
|
24
23
|
getAllForeignKeys(connection: AbstractSqlConnection, tablesBySchemas: Map<string | undefined, Table[]>, ctx?: Transaction): Promise<Dictionary<Dictionary<ForeignKey>>>;
|
|
25
24
|
private getEnumDefinitions;
|
|
26
25
|
private getChecksSQL;
|
package/MsSqlSchemaHelper.js
CHANGED
|
@@ -254,26 +254,24 @@ export class MsSqlSchemaHelper extends SchemaHelper {
|
|
|
254
254
|
}
|
|
255
255
|
return ret;
|
|
256
256
|
}
|
|
257
|
-
mapForeignKeys(fks, tableName, schemaName) {
|
|
258
|
-
const ret = super.mapForeignKeys(fks, tableName, schemaName);
|
|
259
|
-
for (const fk of Utils.values(ret)) {
|
|
260
|
-
fk.columnNames = Utils.unique(fk.columnNames);
|
|
261
|
-
fk.referencedColumnNames = Utils.unique(fk.referencedColumnNames);
|
|
262
|
-
}
|
|
263
|
-
return ret;
|
|
264
|
-
}
|
|
265
257
|
async getAllForeignKeys(connection, tablesBySchemas, ctx) {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
inner join
|
|
275
|
-
|
|
276
|
-
|
|
258
|
+
// `sys.foreign_key_columns` pairs local and referenced columns of composite FKs, `information_schema` can't
|
|
259
|
+
const sql = `select fk.name constraint_name, t.name table_name, s.name schema_name, c.name column_name,
|
|
260
|
+
rs.name referenced_schema_name,
|
|
261
|
+
rc.name referenced_column_name,
|
|
262
|
+
rt.name referenced_table_name,
|
|
263
|
+
replace(fk.update_referential_action_desc, '_', ' ') update_rule,
|
|
264
|
+
replace(fk.delete_referential_action_desc, '_', ' ') delete_rule
|
|
265
|
+
from sys.foreign_keys fk
|
|
266
|
+
inner join sys.foreign_key_columns fkc on fkc.constraint_object_id = fk.object_id
|
|
267
|
+
inner join sys.tables t on t.object_id = fk.parent_object_id
|
|
268
|
+
inner join sys.schemas s on s.schema_id = t.schema_id
|
|
269
|
+
inner join sys.columns c on c.object_id = fkc.parent_object_id and c.column_id = fkc.parent_column_id
|
|
270
|
+
inner join sys.tables rt on rt.object_id = fk.referenced_object_id
|
|
271
|
+
inner join sys.schemas rs on rs.schema_id = rt.schema_id
|
|
272
|
+
inner join sys.columns rc on rc.object_id = fkc.referenced_object_id and rc.column_id = fkc.referenced_column_id
|
|
273
|
+
where (${[...tablesBySchemas.entries()].map(([schema, tables]) => `(t.name in (${tables.map(t => this.platform.quoteValue(t.table_name)).join(',')}) and s.name = '${schema}')`).join(' or ')})
|
|
274
|
+
order by rs.name, rt.name, fkc.constraint_column_id, fk.name`;
|
|
277
275
|
const allFks = await connection.execute(sql, [], 'all', ctx);
|
|
278
276
|
const ret = {};
|
|
279
277
|
for (const fk of allFks) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/mssql",
|
|
3
|
-
"version": "7.2.6-dev.
|
|
3
|
+
"version": "7.2.6-dev.16",
|
|
4
4
|
"description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"data-mapper",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"copy": "node ../../scripts/copy.mjs"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@mikro-orm/sql": "7.2.6-dev.
|
|
50
|
+
"@mikro-orm/sql": "7.2.6-dev.16",
|
|
51
51
|
"kysely": "0.29.6",
|
|
52
52
|
"tarn": "3.1.2",
|
|
53
53
|
"tedious": "20.3.7",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@mikro-orm/core": "^7.2.5"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@mikro-orm/core": "7.2.6-dev.
|
|
60
|
+
"@mikro-orm/core": "7.2.6-dev.16"
|
|
61
61
|
},
|
|
62
62
|
"engines": {
|
|
63
63
|
"node": ">= 22.17.0"
|