@mikro-orm/sql 7.2.6-dev.20 → 7.2.6-dev.21
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
|
@@ -2115,7 +2115,7 @@ export class AbstractSqlDriver extends DatabaseDriver {
|
|
|
2115
2115
|
if (prop.formula) {
|
|
2116
2116
|
const quotedAlias = this.platform.quoteIdentifier(tableAlias).toString();
|
|
2117
2117
|
const table = this.createFormulaTable(quotedAlias, meta, schema);
|
|
2118
|
-
const columns = meta.createColumnMappingObject(p => qb.helper.getTPTAliasForProperty(p.name, tableAlias),
|
|
2118
|
+
const columns = meta.createColumnMappingObject(p => qb.helper.getTPTAliasForProperty(p.name, tableAlias), quotedAlias);
|
|
2119
2119
|
return [raw(`${this.evaluateFormula(prop.formula, columns, table)} as ${aliased}`)];
|
|
2120
2120
|
}
|
|
2121
2121
|
if (prop.customTypes?.some(type => !!type?.convertToJSValueSQL)) {
|
|
@@ -2539,9 +2539,9 @@ export class AbstractSqlDriver extends DatabaseDriver {
|
|
|
2539
2539
|
ret.push('*');
|
|
2540
2540
|
}
|
|
2541
2541
|
if (ret.length > 0 && !hasExplicitFields && addFormulas) {
|
|
2542
|
-
//
|
|
2542
|
+
// `toString()` must yield the quoted alias like `QueryBuilder.finalize()`, which dedupes formulas by rendered SQL
|
|
2543
2543
|
const quotedAlias = this.platform.quoteIdentifier(alias);
|
|
2544
|
-
const columns = meta.createColumnMappingObject(alias);
|
|
2544
|
+
const columns = meta.createColumnMappingObject(alias, quotedAlias.toString());
|
|
2545
2545
|
const effectiveSchema = schema ?? (meta.schema !== '*' ? meta.schema : undefined);
|
|
2546
2546
|
for (const prop of meta.props) {
|
|
2547
2547
|
if (lazyProps.includes(prop)) {
|
|
@@ -330,10 +330,9 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
|
|
|
330
330
|
return columnDefs.map(colDef => {
|
|
331
331
|
const name = unquote(colDef);
|
|
332
332
|
const result = { name };
|
|
333
|
-
//
|
|
334
|
-
// Create a pattern that matches the column name (quoted or unquoted) followed by modifiers
|
|
333
|
+
// Match the column (quoted or unquoted) as a whole list item, so `id` never matches inside `author_id`
|
|
335
334
|
const escapedName = name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
336
|
-
const colPattern = new RegExp(`"?${escapedName}"
|
|
335
|
+
const colPattern = new RegExp(`(?:^|,)\\s*"?${escapedName}"?(?=\\s|,|$)\\s*([^,)]*?)(?:,|$)`, 'i');
|
|
337
336
|
const colMatch = columnsStr.match(colPattern);
|
|
338
337
|
if (colMatch) {
|
|
339
338
|
const modifiers = colMatch[1];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/sql",
|
|
3
|
-
"version": "7.2.6-dev.
|
|
3
|
+
"version": "7.2.6-dev.21",
|
|
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
|
"keywords": [
|
|
6
6
|
"data-mapper",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@mikro-orm/core": "^7.2.5"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mikro-orm/core": "7.2.6-dev.
|
|
56
|
+
"@mikro-orm/core": "7.2.6-dev.21"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|
package/schema/DatabaseTable.js
CHANGED
|
@@ -924,6 +924,17 @@ export class DatabaseTable {
|
|
|
924
924
|
};
|
|
925
925
|
return [expand(rootProp, 1)];
|
|
926
926
|
}
|
|
927
|
+
// object embedded property index, the JSON keys are the field names of the embedded properties
|
|
928
|
+
if (rootProp?.embeddable && rootProp.object && rootProp.embeddedProps[parts[1]]) {
|
|
929
|
+
let p = rootProp.embeddedProps[parts[1]];
|
|
930
|
+
let i = 2;
|
|
931
|
+
while (i < parts.length && p.embeddedProps?.[parts[i]]) {
|
|
932
|
+
p = p.embeddedProps[parts[i]];
|
|
933
|
+
i++;
|
|
934
|
+
}
|
|
935
|
+
// a path below the last embedded property targets plain JSON keys, kept as they are
|
|
936
|
+
return [[...p.embeddedPath, ...parts.slice(i)].join('.')];
|
|
937
|
+
}
|
|
927
938
|
// json index, we need to rename the column only
|
|
928
939
|
if (rootProp) {
|
|
929
940
|
return [prop.replace(root, rootProp.fieldNames[0])];
|