@mikro-orm/sql 7.1.14-dev.0 → 7.1.14-dev.10
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/AbstractSqlPlatform.d.ts +1 -1
- package/AbstractSqlPlatform.js +3 -0
- package/dialects/postgresql/BasePostgreSqlPlatform.d.ts +1 -1
- package/dialects/postgresql/BasePostgreSqlPlatform.js +2 -1
- package/dialects/postgresql/PostgreSqlSchemaHelper.js +1 -1
- package/package.json +2 -2
- package/query/CriteriaNodeFactory.js +4 -0
- package/schema/SchemaComparator.js +4 -4
package/AbstractSqlPlatform.d.ts
CHANGED
|
@@ -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
|
package/AbstractSqlPlatform.js
CHANGED
|
@@ -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
|
|
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 = '->>';
|
|
@@ -494,7 +494,7 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
|
|
|
494
494
|
// SchemaHelper.createCheck).
|
|
495
495
|
const m = /^check \(\((.*)\)\)$/is.exec(check.expression);
|
|
496
496
|
const single = m ? null : /^check \((.*)\)$/is.exec(check.expression);
|
|
497
|
-
const def = m ? m[1].replace(/\(([^()]*)\)::\w
|
|
497
|
+
const def = m ? m[1].replace(/\(([^()]*)\)::\w+(?:\[\])?/g, '$1') : single ? single[1] : check.expression;
|
|
498
498
|
ret[key].push({
|
|
499
499
|
name: check.name,
|
|
500
500
|
columnName: check.column_name,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/sql",
|
|
3
|
-
"version": "7.1.14-dev.
|
|
3
|
+
"version": "7.1.14-dev.10",
|
|
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.
|
|
56
|
+
"@mikro-orm/core": "7.1.14-dev.10"
|
|
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
|
}
|
|
@@ -963,13 +963,13 @@ export class SchemaComparator {
|
|
|
963
963
|
}
|
|
964
964
|
diffTrigger(from, to) {
|
|
965
965
|
// Raw DDL expression cannot be meaningfully compared to introspected
|
|
966
|
-
// trigger metadata, so
|
|
967
|
-
if (to.expression) {
|
|
966
|
+
// trigger metadata, so it needs special handling when either side uses it.
|
|
967
|
+
if (from.expression || to.expression) {
|
|
968
968
|
// Both sides have expression — compare the raw DDL directly
|
|
969
|
-
if (from.expression) {
|
|
969
|
+
if (from.expression && to.expression) {
|
|
970
970
|
return this.diffExpression(from.expression, to.expression);
|
|
971
971
|
}
|
|
972
|
-
// Only
|
|
972
|
+
// Only one side has expression — the raw DDL cannot be compared to
|
|
973
973
|
// introspected metadata. Changes to the expression value won't be detected;
|
|
974
974
|
// drop and recreate the trigger manually to apply expression changes.
|
|
975
975
|
return false;
|