@mikro-orm/knex 6.4.14-dev.9 → 6.4.15-dev.0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "6.4.
|
|
3
|
+
"version": "6.4.15-dev.0",
|
|
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",
|
|
@@ -63,10 +63,10 @@
|
|
|
63
63
|
"sqlstring": "2.3.3"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@mikro-orm/core": "^6.4.
|
|
66
|
+
"@mikro-orm/core": "^6.4.14"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "6.4.
|
|
69
|
+
"@mikro-orm/core": "6.4.15-dev.0",
|
|
70
70
|
"better-sqlite3": "*",
|
|
71
71
|
"libsql": "*",
|
|
72
72
|
"mariadb": "*"
|
package/query/QueryBuilder.js
CHANGED
|
@@ -689,10 +689,7 @@ class QueryBuilder {
|
|
|
689
689
|
}
|
|
690
690
|
const query = this.toQuery()._sql;
|
|
691
691
|
const cached = await this.em?.tryCache(this.mainAlias.entityName, this._cache, ['qb.execute', query.sql, query.bindings, method]);
|
|
692
|
-
if (cached?.data
|
|
693
|
-
return null;
|
|
694
|
-
}
|
|
695
|
-
if (cached?.data) {
|
|
692
|
+
if (cached?.data !== undefined) {
|
|
696
693
|
return cached.data;
|
|
697
694
|
}
|
|
698
695
|
const write = method === 'run' || !this.platform.getConfig().get('preferReadReplicas');
|
|
@@ -282,12 +282,13 @@ class QueryBuilderHelper {
|
|
|
282
282
|
const [fromAlias, fromField] = this.splitField(key);
|
|
283
283
|
const prop = this.getProperty(fromField, fromAlias);
|
|
284
284
|
operator = operator === '$not' ? '$eq' : operator;
|
|
285
|
+
const column = this.mapper(key, undefined, undefined, null);
|
|
285
286
|
if (value === null) {
|
|
286
|
-
return `${this.knex.ref(
|
|
287
|
+
return `${this.knex.ref(column)} is ${operator === '$ne' ? 'not ' : ''}null`;
|
|
287
288
|
}
|
|
288
289
|
if (operator === '$fulltext' && prop) {
|
|
289
290
|
const query = this.knex.raw(this.platform.getFullTextWhereClause(prop), {
|
|
290
|
-
column
|
|
291
|
+
column,
|
|
291
292
|
query: this.knex.raw('?'),
|
|
292
293
|
}).toSQL().toNative();
|
|
293
294
|
params.push(value);
|
|
@@ -296,7 +297,7 @@ class QueryBuilderHelper {
|
|
|
296
297
|
const replacement = this.getOperatorReplacement(operator, { [operator]: value });
|
|
297
298
|
if (['$in', '$nin'].includes(operator) && Array.isArray(value)) {
|
|
298
299
|
params.push(...value);
|
|
299
|
-
return `${this.knex.ref(
|
|
300
|
+
return `${this.knex.ref(column)} ${replacement} (${value.map(() => '?').join(', ')})`;
|
|
300
301
|
}
|
|
301
302
|
if (operator === '$exists') {
|
|
302
303
|
value = null;
|
|
@@ -310,14 +311,13 @@ class QueryBuilderHelper {
|
|
|
310
311
|
}
|
|
311
312
|
return sql;
|
|
312
313
|
}
|
|
313
|
-
const sql = this.mapper(key);
|
|
314
314
|
if (value !== null) {
|
|
315
315
|
if (prop?.customType) {
|
|
316
316
|
value = prop.customType.convertToDatabaseValue(value, this.platform, { fromQuery: true, key, mode: 'query' });
|
|
317
317
|
}
|
|
318
318
|
params.push(value);
|
|
319
319
|
}
|
|
320
|
-
return `${this.knex.ref(
|
|
320
|
+
return `${this.knex.ref(column)} ${replacement} ${value === null ? 'null' : '?'}`;
|
|
321
321
|
}
|
|
322
322
|
wrapQueryGroup(parts, operator = '$and') {
|
|
323
323
|
if (parts.length === 1) {
|
package/schema/DatabaseTable.js
CHANGED
|
@@ -104,7 +104,7 @@ class DatabaseTable {
|
|
|
104
104
|
this.columns[field].default = defaultValue;
|
|
105
105
|
});
|
|
106
106
|
if ([core_1.ReferenceKind.MANY_TO_ONE, core_1.ReferenceKind.ONE_TO_ONE].includes(prop.kind)) {
|
|
107
|
-
const constraintName = this.getIndexName(true, prop.fieldNames, 'foreign');
|
|
107
|
+
const constraintName = this.getIndexName(prop.foreignKeyName ?? true, prop.fieldNames, 'foreign');
|
|
108
108
|
let schema = prop.targetMeta.root.schema === '*' ? this.schema : (prop.targetMeta.root.schema ?? config.get('schema', this.platform.getDefaultSchemaName()));
|
|
109
109
|
if (prop.referencedTableName.includes('.')) {
|
|
110
110
|
schema = undefined;
|