@mikro-orm/sql 7.1.14-dev.1 → 7.1.14-dev.3

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.
@@ -28,7 +28,7 @@ export declare abstract class AbstractSqlPlatform extends Platform {
28
28
  getReleaseSavepointSQL(savepointName: string): string;
29
29
  quoteValue(value: any): string;
30
30
  getSearchJsonPropertySQL(path: string, type: string, aliased: boolean): string | RawQueryFragment;
31
- getSearchJsonPropertyKey(path: string[], type: string, aliased: boolean, value?: unknown): string | RawQueryFragment;
31
+ getSearchJsonPropertyKey(path: string[], type: string, aliased: boolean | string, value?: unknown): string | RawQueryFragment;
32
32
  /**
33
33
  * Quotes a key for use inside a JSON path expression (e.g. `$.key`).
34
34
  * Simple alphanumeric keys are left unquoted; others are wrapped in double quotes
@@ -75,6 +75,9 @@ export class AbstractSqlPlatform extends Platform {
75
75
  getSearchJsonPropertyKey(path, type, aliased, value) {
76
76
  const [a, ...b] = path;
77
77
  const jsonPath = this.quoteValue(`$.${b.map(this.quoteJsonKey).join('.')}`);
78
+ if (typeof aliased === 'string') {
79
+ return raw(`json_extract(${this.quoteIdentifier(`${aliased}.${a}`)}, ${jsonPath})`);
80
+ }
78
81
  if (aliased) {
79
82
  return raw(alias => `json_extract(${this.quoteIdentifier(`${alias}.${a}`)}, ${jsonPath})`);
80
83
  }
@@ -88,7 +88,7 @@ export declare class BasePostgreSqlPlatform extends AbstractSqlPlatform {
88
88
  }): string;
89
89
  getBlobDeclarationSQL(): string;
90
90
  getJsonDeclarationSQL(): string;
91
- getSearchJsonPropertyKey(path: string[], type: string | undefined | Type, aliased: boolean, value?: unknown): string | RawQueryFragment;
91
+ getSearchJsonPropertyKey(path: string[], type: string | undefined | Type, aliased: boolean | string, value?: unknown): string | RawQueryFragment;
92
92
  getJsonIndexDefinition(index: IndexDef): string[];
93
93
  quoteIdentifier(id: string | {
94
94
  toString: () => string;
@@ -285,7 +285,8 @@ export class BasePostgreSqlPlatform extends AbstractSqlPlatform {
285
285
  getSearchJsonPropertyKey(path, type, aliased, value) {
286
286
  const first = path.shift();
287
287
  const last = path.pop();
288
- const root = this.quoteIdentifier(aliased ? `${ALIAS_REPLACEMENT}.${first}` : first);
288
+ const alias = typeof aliased === 'string' ? aliased : ALIAS_REPLACEMENT;
289
+ const root = this.quoteIdentifier(aliased ? `${alias}.${first}` : first);
289
290
  type = typeof type === 'string' ? this.getMappedType(type).runtimeType : String(type);
290
291
  const cast = (key) => raw(type in this.#jsonTypeCasts ? `(${key})::${this.#jsonTypeCasts[type]}` : key);
291
292
  let lastOperator = '->>';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/sql",
3
- "version": "7.1.14-dev.1",
3
+ "version": "7.1.14-dev.3",
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.13"
54
54
  },
55
55
  "peerDependencies": {
56
- "@mikro-orm/core": "7.1.14-dev.1"
56
+ "@mikro-orm/core": "7.1.14-dev.3"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">= 22.17.0"
@@ -57,6 +57,10 @@ export class CriteriaNodeFactory {
57
57
  if (isNotEmbedded && prop?.customType instanceof JsonType) {
58
58
  return this.createScalarNode(metadata, childEntity, val, node, key, validate);
59
59
  }
60
+ // operator payloads under an unresolvable alias-prefixed key (e.g. `a.meta`) are opaque values, not entity criteria
61
+ if (!prop && !rawField && Utils.isOperator(key, false) && String(node.key).includes('.')) {
62
+ return this.createScalarNode(metadata, entityName, val, node, key, validate);
63
+ }
60
64
  if (prop?.kind === ReferenceKind.SCALAR && val != null && Object.keys(val).some(f => f in GroupOperator)) {
61
65
  throw ValidationError.cannotUseGroupOperatorsInsideScalars(entityName, prop.name, payload);
62
66
  }