@mikro-orm/sql
Advanced tools
+2
-2
| { | ||
| "name": "@mikro-orm/sql", | ||
| "version": "7.1.11-dev.4", | ||
| "version": "7.1.11-dev.5", | ||
| "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.", | ||
@@ -56,3 +56,3 @@ "keywords": [ | ||
| "peerDependencies": { | ||
| "@mikro-orm/core": "7.1.11-dev.4" | ||
| "@mikro-orm/core": "7.1.11-dev.5" | ||
| }, | ||
@@ -59,0 +59,0 @@ "engines": { |
@@ -222,2 +222,3 @@ import { DecimalType, EntitySchema, isRaw, ReferenceKind, t, Type, UnknownType, Utils, } from '@mikro-orm/core'; | ||
| index.expression || | ||
| index.where || | ||
| !(index.columnNames[0] in columnFks)) && // Trivial non-composite indexes for scalar props are to be mapped to the column. | ||
@@ -511,3 +512,4 @@ // ignore indexes that don't have all column names (this can happen in sqlite where there is no way to infer this for expressions) | ||
| const possibleIndexes = this.#indexes.filter(index => { | ||
| return (index.columnNames.length === fkColumnsLength && | ||
| return (!index.where && | ||
| index.columnNames.length === fkColumnsLength && | ||
| !currentFk.columnNames.some((columnName, i) => index.columnNames[i] !== columnName)); | ||
@@ -527,3 +529,3 @@ }); | ||
| getIndexProperties(index, columnFks, fksOnColumnProps, fksOnStandaloneProps, namingStrategy) { | ||
| const propBaseNames = new Set(); | ||
| const propBaseNames = new Map(); | ||
| const columnNames = index.columnNames; | ||
@@ -534,2 +536,10 @@ const l = columnNames.length; | ||
| } | ||
| const addPropBaseName = (baseName, position) => { | ||
| const positions = propBaseNames.get(baseName); | ||
| if (positions) { | ||
| positions.last = position; | ||
| return; | ||
| } | ||
| propBaseNames.set(baseName, { first: position, last: position }); | ||
| }; | ||
| for (let i = 0; i < l; ++i) { | ||
@@ -545,3 +555,3 @@ const columnName = columnNames[i]; | ||
| // Add it and move on. | ||
| propBaseNames.add(columnName); | ||
| addPropBaseName(columnName, i); | ||
| continue; | ||
@@ -553,3 +563,3 @@ } | ||
| if (columnPropFk && !columnPropFk.columnNames.some(fkColumnName => !columnNames.includes(fkColumnName))) { | ||
| propBaseNames.add(columnName); | ||
| addPropBaseName(columnName, i); | ||
| continue; | ||
@@ -566,3 +576,3 @@ } | ||
| if (!fk.columnNames.some(fkColumnName => !columnNames.includes(fkColumnName))) { | ||
| propBaseNames.add(propName); | ||
| addPropBaseName(propName, i); | ||
| propAdded = true; | ||
@@ -578,3 +588,6 @@ } | ||
| } | ||
| return Array.from(propBaseNames).map(baseName => this.getPropertyName(namingStrategy, baseName, fksOnColumnProps.get(baseName))); | ||
| // Props sharing their first column would otherwise follow FK discovery order, so break ties on the last one. | ||
| return Array.from(propBaseNames) | ||
| .sort(([, a], [, b]) => a.first - b.first || a.last - b.last) | ||
| .map(([baseName]) => this.getPropertyName(namingStrategy, baseName, fksOnColumnProps.get(baseName))); | ||
| } | ||
@@ -705,5 +718,5 @@ getSafeBaseNameForFkProp(namingStrategy, currentFk, fks, columnName) { | ||
| const index = compositeFkIndexes[prop] || | ||
| this.#indexes.find(idx => idx.columnNames[0] === column.name && !idx.composite && !idx.unique && !idx.primary); | ||
| this.#indexes.find(idx => idx.columnNames[0] === column.name && !idx.composite && !idx.unique && !idx.primary && !idx.where); | ||
| const unique = compositeFkUniques[prop] || | ||
| this.#indexes.find(idx => idx.columnNames[0] === column.name && !idx.composite && idx.unique && !idx.primary); | ||
| this.#indexes.find(idx => idx.columnNames[0] === column.name && !idx.composite && idx.unique && !idx.primary && !idx.where); | ||
| const kind = this.getReferenceKind(fk, unique); | ||
@@ -710,0 +723,0 @@ const runtimeType = this.getPropertyTypeForColumn(namingStrategy, column, fk); |
+2
-2
@@ -371,5 +371,5 @@ import type { Generated, Kysely } from 'kysely'; | ||
| } ? Generated<TValue> : TOptions extends { | ||
| default: true; | ||
| default: unknown; | ||
| } ? Generated<TValue> : TOptions extends { | ||
| defaultRaw: true; | ||
| defaultRaw: unknown; | ||
| } ? Generated<TValue> : TProcessOnCreate extends false ? TValue : TOptions extends { | ||
@@ -376,0 +376,0 @@ onCreate: Function; |
1070849
0.06%22308
0.06%