@mikro-orm/knex 6.1.10-dev.9 → 6.1.11-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/AbstractSqlDriver.js
CHANGED
|
@@ -826,7 +826,7 @@ class AbstractSqlDriver extends core_1.DatabaseDriver {
|
|
|
826
826
|
if (!item[propName]) {
|
|
827
827
|
continue;
|
|
828
828
|
}
|
|
829
|
-
if (
|
|
829
|
+
if ([core_1.ReferenceKind.ONE_TO_MANY, core_1.ReferenceKind.MANY_TO_MANY].includes(prop.kind) && ref) {
|
|
830
830
|
map[pk][propName] = [...map[pk][propName], ...item[propName]];
|
|
831
831
|
continue;
|
|
832
832
|
}
|
package/AbstractSqlPlatform.js
CHANGED
|
@@ -55,8 +55,11 @@ class AbstractSqlPlatform extends core_1.Platform {
|
|
|
55
55
|
getJsonIndexDefinition(index) {
|
|
56
56
|
return index.columnNames
|
|
57
57
|
.map(column => {
|
|
58
|
+
if (!column.includes('.')) {
|
|
59
|
+
return column;
|
|
60
|
+
}
|
|
58
61
|
const [root, ...path] = column.split('.');
|
|
59
|
-
return `json_extract(${root}, '$.${path.join('.')}')`;
|
|
62
|
+
return `(json_extract(${root}, '$.${path.join('.')}'))`;
|
|
60
63
|
});
|
|
61
64
|
}
|
|
62
65
|
isRaw(value) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.11-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,9 +63,9 @@
|
|
|
63
63
|
"sqlstring": "2.3.3"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@mikro-orm/core": "^6.1.
|
|
66
|
+
"@mikro-orm/core": "^6.1.10"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "6.1.
|
|
69
|
+
"@mikro-orm/core": "6.1.11-dev.0"
|
|
70
70
|
}
|
|
71
71
|
}
|
package/query/CriteriaNode.js
CHANGED
|
@@ -69,7 +69,11 @@ class CriteriaNode {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
renameFieldToPK(qb) {
|
|
72
|
-
|
|
72
|
+
let joinAlias = qb.getAliasForJoinPath(this.getPath());
|
|
73
|
+
if (!joinAlias && this.parent && [core_1.ReferenceKind.MANY_TO_ONE, core_1.ReferenceKind.ONE_TO_ONE].includes(this.prop.kind) && this.prop.owner) {
|
|
74
|
+
joinAlias = qb.getAliasForJoinPath(this.parent.getPath());
|
|
75
|
+
return core_1.Utils.getPrimaryKeyHash(this.prop.joinColumns.map(col => `${joinAlias ?? qb.alias}.${col}`));
|
|
76
|
+
}
|
|
73
77
|
const alias = joinAlias ?? qb.alias;
|
|
74
78
|
if (this.prop.kind === core_1.ReferenceKind.MANY_TO_MANY) {
|
|
75
79
|
return core_1.Utils.getPrimaryKeyHash(this.prop.inverseJoinColumns.map(col => `${alias}.${col}`));
|
|
@@ -86,7 +86,11 @@ class QueryBuilderHelper {
|
|
|
86
86
|
const alias2 = this.knex.ref(a).toString();
|
|
87
87
|
const aliased = this.knex.ref(prop.fieldNames[0]).toString();
|
|
88
88
|
const as = alias === null ? '' : ` as ${aliased}`;
|
|
89
|
-
|
|
89
|
+
let value = prop.formula(alias2);
|
|
90
|
+
if (!this.isTableNameAliasRequired(type)) {
|
|
91
|
+
value = value.replaceAll(alias2 + '.', '');
|
|
92
|
+
}
|
|
93
|
+
return this.knex.raw(`${value}${as}`);
|
|
90
94
|
}
|
|
91
95
|
if (prop?.hasConvertToJSValueSQL) {
|
|
92
96
|
let valueSQL;
|
|
@@ -498,7 +498,7 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
|
|
|
498
498
|
// JSON columns can have unique index but not unique constraint, and we need to distinguish those, so we can properly drop them
|
|
499
499
|
if (index.columnNames.some(column => column.includes('.'))) {
|
|
500
500
|
const columns = this.platform.getJsonIndexDefinition(index);
|
|
501
|
-
table.index(columns.map(column => this.knex.raw(
|
|
501
|
+
table.index(columns.map(column => this.knex.raw(column)), index.keyName, { indexType: 'unique' });
|
|
502
502
|
}
|
|
503
503
|
else {
|
|
504
504
|
table.unique(index.columnNames, { indexName: index.keyName });
|
|
@@ -517,7 +517,7 @@ class SqlSchemaGenerator extends core_1.AbstractSchemaGenerator {
|
|
|
517
517
|
// JSON columns can have unique index but not unique constraint, and we need to distinguish those, so we can properly drop them
|
|
518
518
|
if (index.columnNames.some(column => column.includes('.'))) {
|
|
519
519
|
const columns = this.platform.getJsonIndexDefinition(index);
|
|
520
|
-
table.index(columns.map(column => this.knex.raw(
|
|
520
|
+
table.index(columns.map(column => this.knex.raw(column)), index.keyName, index.type);
|
|
521
521
|
}
|
|
522
522
|
else {
|
|
523
523
|
table.index(index.columnNames, index.keyName, index.type);
|