@mikro-orm/knex 6.5.6-dev.12 → 6.5.6-dev.3
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/AbstractSqlDriver.js
CHANGED
|
@@ -392,12 +392,7 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
|
|
|
392
392
|
sql += ' ' + data.map(() => `select null as ${this.platform.quoteIdentifier(pks[0])}`).join(' union all ');
|
|
393
393
|
}
|
|
394
394
|
const addParams = (prop, row) => {
|
|
395
|
-
|
|
396
|
-
if (prop.nullable && rowValue === null) {
|
|
397
|
-
params.push(null);
|
|
398
|
-
return;
|
|
399
|
-
}
|
|
400
|
-
let value = rowValue ?? prop.default;
|
|
395
|
+
let value = row[prop.name] ?? prop.default;
|
|
401
396
|
if (prop.kind === core_1.ReferenceKind.EMBEDDED && prop.object) {
|
|
402
397
|
if (prop.array && value) {
|
|
403
398
|
value = this.platform.cloneEmbeddable(value);
|
|
@@ -79,8 +79,7 @@ class MySqlPlatform extends AbstractSqlPlatform_1.AbstractSqlPlatform {
|
|
|
79
79
|
}
|
|
80
80
|
const indexName = super.getIndexName(tableName, columns, type);
|
|
81
81
|
if (indexName.length > 64) {
|
|
82
|
-
|
|
83
|
-
return `${indexName.substring(0, 56 - type.length)}_${core_1.Utils.hash(indexName, 5, hashAlgorithm)}_${type}`;
|
|
82
|
+
return `${indexName.substring(0, 56 - type.length)}_${core_1.Utils.hash(indexName, 5)}_${type}`;
|
|
84
83
|
}
|
|
85
84
|
return indexName;
|
|
86
85
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "6.5.6-dev.
|
|
3
|
+
"version": "6.5.6-dev.3",
|
|
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
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@mikro-orm/core": "^6.5.5"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "6.5.6-dev.
|
|
69
|
+
"@mikro-orm/core": "6.5.6-dev.3",
|
|
70
70
|
"better-sqlite3": "*",
|
|
71
71
|
"libsql": "*",
|
|
72
72
|
"mariadb": "*"
|
package/schema/DatabaseSchema.js
CHANGED
|
@@ -72,7 +72,6 @@ class DatabaseSchema {
|
|
|
72
72
|
static fromMetadata(metadata, platform, config, schemaName) {
|
|
73
73
|
const schema = new DatabaseSchema(platform, schemaName ?? config.get('schema'));
|
|
74
74
|
const nativeEnums = {};
|
|
75
|
-
const skipColumns = config.get('schemaGenerator').skipColumns || {};
|
|
76
75
|
for (const meta of metadata) {
|
|
77
76
|
for (const prop of meta.props) {
|
|
78
77
|
if (prop.nativeEnumName) {
|
|
@@ -101,7 +100,7 @@ class DatabaseSchema {
|
|
|
101
100
|
const table = schema.addTable(meta.collection, this.getSchemaName(meta, config, schemaName));
|
|
102
101
|
table.comment = meta.comment;
|
|
103
102
|
meta.props
|
|
104
|
-
.filter(prop => this.shouldHaveColumn(meta, prop
|
|
103
|
+
.filter(prop => this.shouldHaveColumn(meta, prop))
|
|
105
104
|
.forEach(prop => table.addColumnFromProperty(prop, meta, config));
|
|
106
105
|
meta.indexes.forEach(index => table.addIndex(meta, index, 'index'));
|
|
107
106
|
meta.uniques.forEach(index => table.addIndex(meta, index, 'unique'));
|
|
@@ -130,25 +129,10 @@ class DatabaseSchema {
|
|
|
130
129
|
return ((takeTables?.some(tableNameToMatch => this.matchName(tableName, tableNameToMatch)) ?? true) &&
|
|
131
130
|
!(skipTables?.some(tableNameToMatch => this.matchName(tableName, tableNameToMatch)) ?? false));
|
|
132
131
|
}
|
|
133
|
-
static shouldHaveColumn(meta, prop
|
|
132
|
+
static shouldHaveColumn(meta, prop) {
|
|
134
133
|
if (prop.persist === false || (prop.columnTypes?.length ?? 0) === 0) {
|
|
135
134
|
return false;
|
|
136
135
|
}
|
|
137
|
-
// Check if column should be skipped
|
|
138
|
-
if (skipColumns) {
|
|
139
|
-
const tableName = meta.tableName;
|
|
140
|
-
const tableSchema = meta.schema;
|
|
141
|
-
const fullTableName = tableSchema ? `${tableSchema}.${tableName}` : tableName;
|
|
142
|
-
// Check for skipColumns by table name or fully qualified table name
|
|
143
|
-
const columnsToSkip = skipColumns[tableName] || skipColumns[fullTableName];
|
|
144
|
-
if (columnsToSkip) {
|
|
145
|
-
for (const fieldName of prop.fieldNames) {
|
|
146
|
-
if (columnsToSkip.some(pattern => this.matchName(fieldName, pattern))) {
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
136
|
if (prop.kind === core_1.ReferenceKind.EMBEDDED && prop.object) {
|
|
153
137
|
return true;
|
|
154
138
|
}
|
package/schema/SchemaHelper.d.ts
CHANGED
|
@@ -73,8 +73,6 @@ export declare abstract class SchemaHelper {
|
|
|
73
73
|
disableForeignKeys?: boolean;
|
|
74
74
|
createForeignKeyConstraints?: boolean;
|
|
75
75
|
ignoreSchema?: string[];
|
|
76
|
-
skipTables?: (string | RegExp)[];
|
|
77
|
-
skipColumns?: Dictionary<(string | RegExp)[]>;
|
|
78
76
|
managementDbName?: string;
|
|
79
77
|
};
|
|
80
78
|
private processComment;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbstractSchemaGenerator, type ClearDatabaseOptions, type CreateSchemaOptions, type DropSchemaOptions, type EnsureDatabaseOptions, type
|
|
1
|
+
import { AbstractSchemaGenerator, type ClearDatabaseOptions, type CreateSchemaOptions, type DropSchemaOptions, type EnsureDatabaseOptions, type ISchemaGenerator, type MikroORM, type Transaction, type UpdateSchemaOptions } from '@mikro-orm/core';
|
|
2
2
|
import type { SchemaDifference } from '../typings';
|
|
3
3
|
import { DatabaseSchema } from './DatabaseSchema';
|
|
4
4
|
import type { AbstractSqlDriver } from '../AbstractSqlDriver';
|
|
@@ -8,8 +8,6 @@ export declare class SqlSchemaGenerator extends AbstractSchemaGenerator<Abstract
|
|
|
8
8
|
disableForeignKeys?: boolean;
|
|
9
9
|
createForeignKeyConstraints?: boolean;
|
|
10
10
|
ignoreSchema?: string[];
|
|
11
|
-
skipTables?: (string | RegExp)[];
|
|
12
|
-
skipColumns?: import("@mikro-orm/core").Dictionary<(string | RegExp)[]>;
|
|
13
11
|
managementDbName?: string;
|
|
14
12
|
};
|
|
15
13
|
protected lastEnsuredDatabase?: string;
|
|
@@ -20,7 +18,6 @@ export declare class SqlSchemaGenerator extends AbstractSchemaGenerator<Abstract
|
|
|
20
18
|
*/
|
|
21
19
|
ensureDatabase(options?: EnsureDatabaseOptions): Promise<boolean>;
|
|
22
20
|
getTargetSchema(schema?: string): DatabaseSchema;
|
|
23
|
-
protected getOrderedMetadata(schema?: string): EntityMetadata[];
|
|
24
21
|
getCreateSchemaSQL(options?: CreateSchemaOptions): Promise<string>;
|
|
25
22
|
dropSchema(options?: DropSchemaOptions): Promise<void>;
|
|
26
23
|
createNamespace(name: string): Promise<void>;
|
|
@@ -63,7 +60,5 @@ export declare class SqlSchemaGenerator extends AbstractSchemaGenerator<Abstract
|
|
|
63
60
|
private createForeignKeys;
|
|
64
61
|
private dump;
|
|
65
62
|
private get knex();
|
|
66
|
-
private matchName;
|
|
67
|
-
private isTableSkipped;
|
|
68
63
|
}
|
|
69
64
|
export { SqlSchemaGenerator as SchemaGenerator };
|
|
@@ -50,15 +50,6 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
|
|
|
50
50
|
const schemaName = schema ?? this.config.get('schema') ?? this.platform.getDefaultSchemaName();
|
|
51
51
|
return DatabaseSchema_1.DatabaseSchema.fromMetadata(metadata, this.platform, this.config, schemaName);
|
|
52
52
|
}
|
|
53
|
-
getOrderedMetadata(schema) {
|
|
54
|
-
const metadata = super.getOrderedMetadata(schema);
|
|
55
|
-
// Filter out skipped tables
|
|
56
|
-
return metadata.filter(meta => {
|
|
57
|
-
const tableName = meta.tableName;
|
|
58
|
-
const tableSchema = meta.schema ?? schema ?? this.config.get('schema');
|
|
59
|
-
return !this.isTableSkipped(tableName, tableSchema);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
53
|
async getCreateSchemaSQL(options = {}) {
|
|
63
54
|
const toSchema = this.getTargetSchema(options.schema);
|
|
64
55
|
let ret = '';
|
|
@@ -495,19 +486,6 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
|
|
|
495
486
|
get knex() {
|
|
496
487
|
return this.connection.getKnex();
|
|
497
488
|
}
|
|
498
|
-
matchName(name, nameToMatch) {
|
|
499
|
-
return typeof nameToMatch === 'string'
|
|
500
|
-
? name.toLocaleLowerCase() === nameToMatch.toLocaleLowerCase()
|
|
501
|
-
: nameToMatch.test(name);
|
|
502
|
-
}
|
|
503
|
-
isTableSkipped(tableName, schemaName) {
|
|
504
|
-
const skipTables = this.options.skipTables;
|
|
505
|
-
if (!skipTables || skipTables.length === 0) {
|
|
506
|
-
return false;
|
|
507
|
-
}
|
|
508
|
-
const fullTableName = schemaName ? `${schemaName}.${tableName}` : tableName;
|
|
509
|
-
return skipTables.some(pattern => this.matchName(tableName, pattern) || this.matchName(fullTableName, pattern));
|
|
510
|
-
}
|
|
511
489
|
}
|
|
512
490
|
exports.SqlSchemaGenerator = SqlSchemaGenerator;
|
|
513
491
|
exports.SchemaGenerator = SqlSchemaGenerator;
|