@mikro-orm/sql 7.1.5-dev.22 → 7.1.5-dev.24

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.
@@ -2214,6 +2214,20 @@ export class AbstractSqlDriver extends DatabaseDriver {
2214
2214
  const join = qb.getJoinForPath(path, { matchPopulateJoins: true });
2215
2215
  const propAlias = qb.getAliasForJoinPath(join ?? path, { matchPopulateJoins: true }) ?? parentAlias;
2216
2216
  if (!join) {
2217
+ // an owner to-one relation that is not joined (e.g. ordering a populated collection by such
2218
+ // a relation's primary key) can be ordered by its local FK columns, matching the `select-in`
2219
+ // and `balanced` strategies instead of silently dropping the clause
2220
+ if (prop.owner &&
2221
+ [ReferenceKind.MANY_TO_ONE, ReferenceKind.ONE_TO_ONE].includes(prop.kind) &&
2222
+ Utils.isPlainObject(childOrder)) {
2223
+ for (const childField of Utils.getObjectQueryKeys(childOrder)) {
2224
+ const idx = prop.referencedPKs.indexOf(childField);
2225
+ const order = childOrder[childField];
2226
+ if (idx !== -1 && order) {
2227
+ orderBy.push({ [`${parentAlias}.${prop.joinColumns[idx]}`]: order });
2228
+ }
2229
+ }
2230
+ }
2217
2231
  continue;
2218
2232
  }
2219
2233
  if (join &&
@@ -603,7 +603,8 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
603
603
  .map(p => {
604
604
  const dir = p.direction === 'in' ? '' : `${p.direction.toUpperCase()} `;
605
605
  const def = p.defaultRaw ? ` default ${p.defaultRaw}` : '';
606
- return `${dir}${this.platform.quoteIdentifier(p.name)} ${p.type}${def}`;
606
+ const name = p.name ? `${this.platform.quoteIdentifier(p.name)} ` : '';
607
+ return `${dir}${name}${p.type}${def}`;
607
608
  })
608
609
  .join(', ');
609
610
  }
@@ -614,15 +615,16 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
614
615
  return signature.split(/,(?![^()]*\))/).map(part => {
615
616
  const trimmed = part.trim();
616
617
  // INOUT before IN/OUT, with required trailing space so identifiers like `input` aren't
617
- // mis-parsed as a direction keyword.
618
- const match = /^(?:(INOUT|VARIADIC|IN|OUT)\s+)?(?:"((?:[^"]|"")+)"|([\w$]+))\s+(.+?)(?:\s+default\s+.+)?$/i.exec(trimmed);
618
+ // mis-parsed as a direction keyword. The name is optional — `pg_get_function_arguments`
619
+ // omits it for unnamed parameters (e.g. `text`), leaving just the type.
620
+ const match = /^(?:(INOUT|VARIADIC|IN|OUT)\s+)?(?:(?:"((?:[^"]|"")+)"|([\w$]+))\s+)?(.+?)(?:\s+default\s+.+)?$/i.exec(trimmed);
619
621
  /* v8 ignore next 3: defensive guard for unexpected `pg_get_function_arguments` output shapes */
620
622
  if (!match) {
621
623
  throw new Error(`Could not parse PostgreSQL routine parameter signature: ${JSON.stringify(trimmed)}`);
622
624
  }
623
625
  const dirRaw = (match[1] ?? 'in').toLowerCase();
624
626
  const direction = dirRaw === 'inout' ? 'inout' : dirRaw === 'out' ? 'out' : 'in';
625
- const name = match[2] != null ? match[2].replaceAll('""', '"') : match[3];
627
+ const name = match[2] != null ? match[2].replaceAll('""', '"') : (match[3] ?? '');
626
628
  return {
627
629
  name,
628
630
  type: match[4].trim(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/sql",
3
- "version": "7.1.5-dev.22",
3
+ "version": "7.1.5-dev.24",
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.1.4"
54
54
  },
55
55
  "peerDependencies": {
56
- "@mikro-orm/core": "7.1.5-dev.22"
56
+ "@mikro-orm/core": "7.1.5-dev.24"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">= 22.17.0"