@mikro-orm/knex 6.3.14-dev.4 → 6.3.14-dev.41
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/index.mjs +1 -0
- package/package.json +2 -2
- package/query/QueryBuilder.js +3 -2
- package/query/QueryBuilderHelper.js +1 -1
- package/schema/DatabaseSchema.d.ts +3 -1
- package/schema/DatabaseSchema.js +11 -2
package/index.mjs
CHANGED
|
@@ -199,6 +199,7 @@ export const TimeType = mod.TimeType;
|
|
|
199
199
|
export const TinyIntType = mod.TinyIntType;
|
|
200
200
|
export const TransactionContext = mod.TransactionContext;
|
|
201
201
|
export const TransactionEventBroadcaster = mod.TransactionEventBroadcaster;
|
|
202
|
+
export const Transactional = mod.Transactional;
|
|
202
203
|
export const Type = mod.Type;
|
|
203
204
|
export const Uint8ArrayType = mod.Uint8ArrayType;
|
|
204
205
|
export const UnderscoreNamingStrategy = mod.UnderscoreNamingStrategy;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "6.3.14-dev.
|
|
3
|
+
"version": "6.3.14-dev.41",
|
|
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.3.13"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "6.3.14-dev.
|
|
69
|
+
"@mikro-orm/core": "6.3.14-dev.41",
|
|
70
70
|
"better-sqlite3": "*",
|
|
71
71
|
"libsql": "*",
|
|
72
72
|
"mariadb": "*"
|
package/query/QueryBuilder.js
CHANGED
|
@@ -691,7 +691,6 @@ class QueryBuilder {
|
|
|
691
691
|
const [propName] = hint.field.split(':', 2);
|
|
692
692
|
const value = core_1.Reference.unwrapReference(entity[propName]);
|
|
693
693
|
if (core_1.Utils.isEntity(value)) {
|
|
694
|
-
(0, core_1.helper)(value).populated();
|
|
695
694
|
propagatePopulateHint(value, hint.children ?? []);
|
|
696
695
|
}
|
|
697
696
|
else if (core_1.Utils.isCollection(value)) {
|
|
@@ -1051,7 +1050,7 @@ class QueryBuilder {
|
|
|
1051
1050
|
case enums_1.QueryType.SELECT:
|
|
1052
1051
|
qb.select(this.prepareFields(this._fields));
|
|
1053
1052
|
if (this._distinctOn) {
|
|
1054
|
-
qb.distinctOn(this._distinctOn);
|
|
1053
|
+
qb.distinctOn(this.prepareFields(this._distinctOn));
|
|
1055
1054
|
}
|
|
1056
1055
|
else if (this.flags.has(core_1.QueryFlag.DISTINCT)) {
|
|
1057
1056
|
qb.distinct();
|
|
@@ -1069,6 +1068,7 @@ class QueryBuilder {
|
|
|
1069
1068
|
break;
|
|
1070
1069
|
case enums_1.QueryType.UPDATE:
|
|
1071
1070
|
qb.update(this._data);
|
|
1071
|
+
this.helper.processJoins(qb, this._joins, joinSchema);
|
|
1072
1072
|
this.helper.updateVersionProperty(qb, this._data);
|
|
1073
1073
|
break;
|
|
1074
1074
|
case enums_1.QueryType.DELETE:
|
|
@@ -1337,6 +1337,7 @@ class QueryBuilder {
|
|
|
1337
1337
|
subSubQuery.__raw = true; // tag it as there is now way to check via `instanceof`
|
|
1338
1338
|
const method = this.flags.has(core_1.QueryFlag.UPDATE_SUB_QUERY) ? 'update' : 'delete';
|
|
1339
1339
|
this._cond = {}; // otherwise we would trigger validation error
|
|
1340
|
+
this._joins = {}; // included in the subquery
|
|
1340
1341
|
this[method](this._data).where({
|
|
1341
1342
|
[core_1.Utils.getPrimaryKeyHash(meta.primaryKeys)]: { $in: subSubQuery },
|
|
1342
1343
|
});
|
|
@@ -583,7 +583,7 @@ class QueryBuilderHelper {
|
|
|
583
583
|
return;
|
|
584
584
|
}
|
|
585
585
|
if (type === enums_1.QueryType.UPDATE) {
|
|
586
|
-
const returningProps = meta.hydrateProps.filter(prop => core_1.Utils.isRawSql(data[prop.
|
|
586
|
+
const returningProps = meta.hydrateProps.filter(prop => prop.fieldNames && core_1.Utils.isRawSql(data[prop.fieldNames[0]]));
|
|
587
587
|
if (returningProps.length > 0) {
|
|
588
588
|
qb.returning(returningProps.flatMap(prop => {
|
|
589
589
|
if (prop.hasConvertToJSValueSQL) {
|
|
@@ -34,9 +34,11 @@ export declare class DatabaseSchema {
|
|
|
34
34
|
hasNamespace(namespace: string): boolean;
|
|
35
35
|
hasNativeEnum(name: string): boolean;
|
|
36
36
|
getNamespaces(): string[];
|
|
37
|
-
static create(connection: AbstractSqlConnection, platform: AbstractSqlPlatform, config: Configuration, schemaName?: string, schemas?: string[]): Promise<DatabaseSchema>;
|
|
37
|
+
static create(connection: AbstractSqlConnection, platform: AbstractSqlPlatform, config: Configuration, schemaName?: string, schemas?: string[], takeTables?: (string | RegExp)[], skipTables?: (string | RegExp)[]): Promise<DatabaseSchema>;
|
|
38
38
|
static fromMetadata(metadata: EntityMetadata[], platform: AbstractSqlPlatform, config: Configuration, schemaName?: string): DatabaseSchema;
|
|
39
39
|
private static getSchemaName;
|
|
40
|
+
private static matchName;
|
|
41
|
+
private static isTableNameAllowed;
|
|
40
42
|
private static shouldHaveColumn;
|
|
41
43
|
toJSON(): Dictionary;
|
|
42
44
|
prune(schema: string | undefined, wildcardSchemaTables: string[]): void;
|
package/schema/DatabaseSchema.js
CHANGED
|
@@ -59,13 +59,13 @@ class DatabaseSchema {
|
|
|
59
59
|
getNamespaces() {
|
|
60
60
|
return [...this.namespaces];
|
|
61
61
|
}
|
|
62
|
-
static async create(connection, platform, config, schemaName, schemas) {
|
|
62
|
+
static async create(connection, platform, config, schemaName, schemas, takeTables, skipTables) {
|
|
63
63
|
const schema = new DatabaseSchema(platform, schemaName ?? config.get('schema') ?? platform.getDefaultSchemaName());
|
|
64
64
|
const allTables = await connection.execute(platform.getSchemaHelper().getListTablesSQL());
|
|
65
65
|
const parts = config.get('migrations').tableName.split('.');
|
|
66
66
|
const migrationsTableName = parts[1] ?? parts[0];
|
|
67
67
|
const migrationsSchemaName = parts.length > 1 ? parts[0] : config.get('schema', platform.getDefaultSchemaName());
|
|
68
|
-
const tables = allTables.filter(t => t.table_name !== migrationsTableName || (t.schema_name && t.schema_name !== migrationsSchemaName));
|
|
68
|
+
const tables = allTables.filter(t => this.isTableNameAllowed(t.table_name, takeTables, skipTables) && (t.table_name !== migrationsTableName || (t.schema_name && t.schema_name !== migrationsSchemaName)));
|
|
69
69
|
await platform.getSchemaHelper().loadInformationSchema(schema, connection, tables, schemas && schemas.length > 0 ? schemas : undefined);
|
|
70
70
|
return schema;
|
|
71
71
|
}
|
|
@@ -120,6 +120,15 @@ class DatabaseSchema {
|
|
|
120
120
|
static getSchemaName(meta, config, schema) {
|
|
121
121
|
return (meta.schema === '*' ? schema : meta.schema) ?? config.get('schema');
|
|
122
122
|
}
|
|
123
|
+
static matchName(name, nameToMatch) {
|
|
124
|
+
return typeof nameToMatch === 'string'
|
|
125
|
+
? name.toLocaleLowerCase() === nameToMatch.toLocaleLowerCase()
|
|
126
|
+
: nameToMatch.test(name);
|
|
127
|
+
}
|
|
128
|
+
static isTableNameAllowed(tableName, takeTables, skipTables) {
|
|
129
|
+
return ((takeTables?.some(tableNameToMatch => this.matchName(tableName, tableNameToMatch)) ?? true) &&
|
|
130
|
+
!(skipTables?.some(tableNameToMatch => this.matchName(tableName, tableNameToMatch)) ?? false));
|
|
131
|
+
}
|
|
123
132
|
static shouldHaveColumn(meta, prop) {
|
|
124
133
|
if (prop.persist === false || (prop.columnTypes?.length ?? 0) === 0) {
|
|
125
134
|
return false;
|