@mikro-orm/knex 6.4.8-dev.9 → 6.4.9-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 +3 -3
- package/schema/DatabaseTable.js +15 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "6.4.
|
|
3
|
+
"version": "6.4.9-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.8"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@mikro-orm/core": "6.4.
|
|
69
|
+
"@mikro-orm/core": "6.4.9-dev.0",
|
|
70
70
|
"better-sqlite3": "*",
|
|
71
71
|
"libsql": "*",
|
|
72
72
|
"mariadb": "*"
|
package/schema/DatabaseTable.js
CHANGED
|
@@ -698,16 +698,28 @@ class DatabaseTable {
|
|
|
698
698
|
}
|
|
699
699
|
addIndex(meta, index, type) {
|
|
700
700
|
const properties = core_1.Utils.unique(core_1.Utils.flatten(core_1.Utils.asArray(index.properties).map(prop => {
|
|
701
|
-
const
|
|
701
|
+
const parts = prop.split('.');
|
|
702
|
+
const root = parts[0];
|
|
702
703
|
if (meta.properties[prop]) {
|
|
703
704
|
if (meta.properties[prop].embeddedPath) {
|
|
704
705
|
return [meta.properties[prop].embeddedPath.join('.')];
|
|
705
706
|
}
|
|
706
707
|
return meta.properties[prop].fieldNames;
|
|
707
708
|
}
|
|
709
|
+
const rootProp = meta.properties[root];
|
|
710
|
+
// inline embedded property index, we need to find the field name of the child property
|
|
711
|
+
if (rootProp?.embeddable && !rootProp.object && parts.length > 1) {
|
|
712
|
+
const expand = (p, i) => {
|
|
713
|
+
if (parts.length === i) {
|
|
714
|
+
return p.fieldNames[0];
|
|
715
|
+
}
|
|
716
|
+
return expand(p.embeddedProps[parts[i]], i + 1);
|
|
717
|
+
};
|
|
718
|
+
return [expand(rootProp, 1)];
|
|
719
|
+
}
|
|
708
720
|
// json index, we need to rename the column only
|
|
709
|
-
if (
|
|
710
|
-
return [prop.replace(root,
|
|
721
|
+
if (rootProp) {
|
|
722
|
+
return [prop.replace(root, rootProp.fieldNames[0])];
|
|
711
723
|
}
|
|
712
724
|
/* istanbul ignore next */
|
|
713
725
|
return [prop];
|