@mikro-orm/sql
Advanced tools
@@ -31,3 +31,3 @@ import { type RawQueryFragment, type Constructor, type EntityManager, type EntityRepository, type IDatabaseDriver, type IsolationLevel, type MikroORM, Platform } from '@mikro-orm/core'; | ||
| getSearchJsonPropertySQL(path: string, type: string, aliased: boolean): string | RawQueryFragment; | ||
| getSearchJsonPropertyKey(path: string[], type: string, aliased: boolean, value?: unknown): string | RawQueryFragment; | ||
| getSearchJsonPropertyKey(path: string[], type: string, aliased: boolean | string, value?: unknown): string | RawQueryFragment; | ||
| /** | ||
@@ -34,0 +34,0 @@ * Quotes a key for use inside a JSON path expression (e.g. `$.key`). |
@@ -78,2 +78,5 @@ import { isRaw, JsonProperty, Platform, raw, Utils, } from '@mikro-orm/core'; | ||
| const jsonPath = this.quoteValue(`$.${b.map(this.quoteJsonKey).join('.')}`); | ||
| if (typeof aliased === 'string') { | ||
| return raw(`json_extract(${this.quoteIdentifier(`${aliased}.${a}`)}, ${jsonPath})`); | ||
| } | ||
| if (aliased) { | ||
@@ -80,0 +83,0 @@ return raw(alias => `json_extract(${this.quoteIdentifier(`${alias}.${a}`)}, ${jsonPath})`); |
@@ -91,3 +91,3 @@ import { type EntityProperty, type IsolationLevel, RawQueryFragment, type SimpleColumnMeta, Type } from '@mikro-orm/core'; | ||
| getJsonDeclarationSQL(): string; | ||
| getSearchJsonPropertyKey(path: string[], type: string | undefined | Type, aliased: boolean, value?: unknown): string | RawQueryFragment; | ||
| getSearchJsonPropertyKey(path: string[], type: string | undefined | Type, aliased: boolean | string, value?: unknown): string | RawQueryFragment; | ||
| getJsonIndexDefinition(index: IndexDef): string[]; | ||
@@ -94,0 +94,0 @@ quoteIdentifier(id: string | { |
@@ -288,3 +288,4 @@ import { ALIAS_REPLACEMENT, ARRAY_OPERATORS, raw, RawQueryFragment, Type, Utils, } from '@mikro-orm/core'; | ||
| const last = path.pop(); | ||
| const root = this.quoteIdentifier(aliased ? `${ALIAS_REPLACEMENT}.${first}` : first); | ||
| const alias = typeof aliased === 'string' ? aliased : ALIAS_REPLACEMENT; | ||
| const root = this.quoteIdentifier(aliased ? `${alias}.${first}` : first); | ||
| type = typeof type === 'string' ? this.getMappedType(type).runtimeType : String(type); | ||
@@ -291,0 +292,0 @@ const cast = (key) => raw(type in this.#jsonTypeCasts ? `(${key})::${this.#jsonTypeCasts[type]}` : key); |
+2
-2
| { | ||
| "name": "@mikro-orm/sql", | ||
| "version": "7.1.14-dev.2", | ||
| "version": "7.1.14-dev.3", | ||
| "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.14-dev.2" | ||
| "@mikro-orm/core": "7.1.14-dev.3" | ||
| }, | ||
@@ -59,0 +59,0 @@ "engines": { |
@@ -60,2 +60,6 @@ import { GroupOperator, isRaw, JsonType, RawQueryFragment, ReferenceKind, Utils, ValidationError, } from '@mikro-orm/core'; | ||
| } | ||
| // operator payloads under an unresolvable alias-prefixed key (e.g. `a.meta`) are opaque values, not entity criteria | ||
| if (!prop && !rawField && Utils.isOperator(key, false) && String(node.key).includes('.')) { | ||
| return this.createScalarNode(metadata, entityName, val, node, key, validate); | ||
| } | ||
| if (prop?.kind === ReferenceKind.SCALAR && val != null && Object.keys(val).some(f => f in GroupOperator)) { | ||
@@ -62,0 +66,0 @@ throw ValidationError.cannotUseGroupOperatorsInsideScalars(entityName, prop.name, payload); |
1084969
0.05%22580
0.04%