@mikro-orm/knex 7.0.0-dev.65 → 7.0.0-dev.67
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/dialects/sqlite/BaseSqlitePlatform.js +1 -2
- package/package.json +2 -2
- package/query/CriteriaNodeFactory.js +2 -2
- package/query/ObjectCriteriaNode.js +2 -2
- package/query/QueryBuilder.js +3 -3
- package/query/QueryBuilderHelper.js +2 -2
- package/query/ScalarCriteriaNode.js +2 -2
- package/schema/DatabaseTable.d.ts +1 -1
- package/schema/DatabaseTable.js +3 -3
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Utils } from '@mikro-orm/core';
|
|
2
1
|
import { AbstractSqlPlatform } from '../../AbstractSqlPlatform.js';
|
|
3
2
|
import { SqliteNativeQueryBuilder } from './SqliteNativeQueryBuilder.js';
|
|
4
3
|
import { SqliteSchemaHelper } from './SqliteSchemaHelper.js';
|
|
@@ -29,7 +28,7 @@ export class BaseSqlitePlatform extends AbstractSqlPlatform {
|
|
|
29
28
|
return ['begin'];
|
|
30
29
|
}
|
|
31
30
|
getEnumTypeDeclarationSQL(column) {
|
|
32
|
-
if (column.items?.every(item =>
|
|
31
|
+
if (column.items?.every(item => typeof item === 'string')) {
|
|
33
32
|
return 'text';
|
|
34
33
|
}
|
|
35
34
|
/* v8 ignore next */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/knex",
|
|
3
|
-
"version": "7.0.0-dev.
|
|
3
|
+
"version": "7.0.0-dev.67",
|
|
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
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -57,6 +57,6 @@
|
|
|
57
57
|
"@mikro-orm/core": "^6.6.1"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@mikro-orm/core": "7.0.0-dev.
|
|
60
|
+
"@mikro-orm/core": "7.0.0-dev.67"
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isRaw, JsonType, RawQueryFragment, ReferenceKind, Utils, ValidationError, } from '@mikro-orm/core';
|
|
1
|
+
import { GroupOperator, isRaw, JsonType, RawQueryFragment, ReferenceKind, Utils, ValidationError, } from '@mikro-orm/core';
|
|
2
2
|
import { ObjectCriteriaNode } from './ObjectCriteriaNode.js';
|
|
3
3
|
import { ArrayCriteriaNode } from './ArrayCriteriaNode.js';
|
|
4
4
|
import { ScalarCriteriaNode } from './ScalarCriteriaNode.js';
|
|
@@ -50,7 +50,7 @@ export class CriteriaNodeFactory {
|
|
|
50
50
|
if (isNotEmbedded && prop?.customType instanceof JsonType) {
|
|
51
51
|
return this.createScalarNode(metadata, childEntity, payload[key], node, key);
|
|
52
52
|
}
|
|
53
|
-
if (prop?.kind === ReferenceKind.SCALAR && payload[key] != null && Object.keys(payload[key]).some(f =>
|
|
53
|
+
if (prop?.kind === ReferenceKind.SCALAR && payload[key] != null && Object.keys(payload[key]).some(f => f in GroupOperator)) {
|
|
54
54
|
throw ValidationError.cannotUseGroupOperatorsInsideScalars(entityName, prop.name, payload);
|
|
55
55
|
}
|
|
56
56
|
if (isNotEmbedded) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ALIAS_REPLACEMENT, QueryFlag, raw, RawQueryFragment, ReferenceKind, Utils, } from '@mikro-orm/core';
|
|
1
|
+
import { ALIAS_REPLACEMENT, GroupOperator, QueryFlag, raw, RawQueryFragment, ReferenceKind, Utils, } from '@mikro-orm/core';
|
|
2
2
|
import { CriteriaNode } from './CriteriaNode.js';
|
|
3
3
|
import { JoinType, QueryType } from './enums.js';
|
|
4
4
|
/**
|
|
@@ -160,7 +160,7 @@ export class ObjectCriteriaNode extends CriteriaNode {
|
|
|
160
160
|
delete payload[k];
|
|
161
161
|
o[this.aliased(field, alias)] = { [k]: tmp, ...o[this.aliased(field, alias)] };
|
|
162
162
|
}
|
|
163
|
-
else if (
|
|
163
|
+
else if (k in GroupOperator && Array.isArray(payload[k])) {
|
|
164
164
|
this.inlineArrayChildPayload(o, payload[k], k, prop, childAlias, alias);
|
|
165
165
|
}
|
|
166
166
|
else if (this.isPrefixed(k) || Utils.isOperator(k) || !childAlias) {
|
package/query/QueryBuilder.js
CHANGED
|
@@ -313,7 +313,7 @@ export class QueryBuilder {
|
|
|
313
313
|
cond = { [raw(`(${sql})`)]: Utils.asArray(params) };
|
|
314
314
|
operator ??= '$and';
|
|
315
315
|
}
|
|
316
|
-
else if (
|
|
316
|
+
else if (typeof cond === 'string') {
|
|
317
317
|
cond = { [raw(`(${cond})`, Utils.asArray(params))]: [] };
|
|
318
318
|
operator ??= '$and';
|
|
319
319
|
}
|
|
@@ -392,7 +392,7 @@ export class QueryBuilder {
|
|
|
392
392
|
}
|
|
393
393
|
having(cond = {}, params, operator) {
|
|
394
394
|
this.ensureNotFinalized();
|
|
395
|
-
if (
|
|
395
|
+
if (typeof cond === 'string') {
|
|
396
396
|
cond = { [raw(`(${cond})`, params)]: [] };
|
|
397
397
|
}
|
|
398
398
|
cond = CriteriaNodeFactory.createNode(this.metadata, this.mainAlias.entityName, cond).process(this);
|
|
@@ -1035,7 +1035,7 @@ export class QueryBuilder {
|
|
|
1035
1035
|
ret.push(rawField);
|
|
1036
1036
|
return;
|
|
1037
1037
|
}
|
|
1038
|
-
if (
|
|
1038
|
+
if (typeof field !== 'string') {
|
|
1039
1039
|
ret.push(field);
|
|
1040
1040
|
return;
|
|
1041
1041
|
}
|
|
@@ -539,7 +539,7 @@ export class QueryBuilderHelper {
|
|
|
539
539
|
const ret = [];
|
|
540
540
|
for (const key of Object.keys(orderBy)) {
|
|
541
541
|
const direction = orderBy[key];
|
|
542
|
-
const order =
|
|
542
|
+
const order = typeof direction === 'number' ? QueryOrderNumeric[direction] : direction;
|
|
543
543
|
const raw = RawQueryFragment.getKnownFragment(key);
|
|
544
544
|
if (raw) {
|
|
545
545
|
ret.push(...this.platform.getOrderByExpression(this.platform.formatQuery(raw.sql, raw.params), order));
|
|
@@ -553,7 +553,7 @@ export class QueryBuilderHelper {
|
|
|
553
553
|
const noPrefix = (prop?.persist === false && !prop.formula && !prop.embedded) || RawQueryFragment.isKnownFragment(f);
|
|
554
554
|
const column = this.mapper(noPrefix ? field : `${alias}.${field}`, type, undefined, null);
|
|
555
555
|
/* v8 ignore next */
|
|
556
|
-
const rawColumn =
|
|
556
|
+
const rawColumn = typeof column === 'string' ? column.split('.').map(e => this.platform.quoteIdentifier(e)).join('.') : column;
|
|
557
557
|
const customOrder = prop?.customOrder;
|
|
558
558
|
let colPart = customOrder
|
|
559
559
|
? this.platform.generateCustomOrder(rawColumn, customOrder)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ARRAY_OPERATORS, ReferenceKind } from '@mikro-orm/core';
|
|
2
2
|
import { CriteriaNode } from './CriteriaNode.js';
|
|
3
3
|
import { JoinType, QueryType } from './enums.js';
|
|
4
4
|
import { QueryBuilder } from './QueryBuilder.js';
|
|
@@ -25,7 +25,7 @@ export class ScalarCriteriaNode extends CriteriaNode {
|
|
|
25
25
|
return this.payload.getNativeQuery().toRaw();
|
|
26
26
|
}
|
|
27
27
|
if (this.payload && typeof this.payload === 'object') {
|
|
28
|
-
const keys = Object.keys(this.payload).filter(key =>
|
|
28
|
+
const keys = Object.keys(this.payload).filter(key => ARRAY_OPERATORS.includes(key) && Array.isArray(this.payload[key]));
|
|
29
29
|
for (const key of keys) {
|
|
30
30
|
this.payload[key] = JSON.stringify(this.payload[key]);
|
|
31
31
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Configuration, type DeferMode, type Dictionary, type EntityMetadata, type EntityProperty, type
|
|
1
|
+
import { type Configuration, type DeferMode, type Dictionary, type EntityMetadata, type EntityProperty, type IndexCallback, type NamingStrategy } from '@mikro-orm/core';
|
|
2
2
|
import type { SchemaHelper } from './SchemaHelper.js';
|
|
3
3
|
import type { CheckDef, Column, ForeignKey, IndexDef } from '../typings.js';
|
|
4
4
|
import type { AbstractSqlPlatform } from '../AbstractSqlPlatform.js';
|
package/schema/DatabaseTable.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Cascade, DecimalType, EntitySchema, ReferenceKind, t, Type, UnknownType, Utils,
|
|
1
|
+
import { Cascade, DecimalType, EntitySchema, RawQueryFragment, ReferenceKind, t, Type, UnknownType, Utils, } from '@mikro-orm/core';
|
|
2
2
|
/**
|
|
3
3
|
* @internal
|
|
4
4
|
*/
|
|
@@ -91,7 +91,7 @@ export class DatabaseTable {
|
|
|
91
91
|
precision: prop.precision,
|
|
92
92
|
scale: prop.scale,
|
|
93
93
|
default: prop.defaultRaw,
|
|
94
|
-
enumItems: prop.nativeEnumName || prop.items?.every(
|
|
94
|
+
enumItems: prop.nativeEnumName || prop.items?.every(i => typeof i === 'string') ? prop.items : undefined,
|
|
95
95
|
comment: prop.comment,
|
|
96
96
|
extra: prop.extra,
|
|
97
97
|
ignoreSchemaChanges: prop.ignoreSchemaChanges,
|
|
@@ -162,7 +162,7 @@ export class DatabaseTable {
|
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
getIndexName(value, columnNames, type) {
|
|
165
|
-
if (
|
|
165
|
+
if (typeof value === 'string') {
|
|
166
166
|
return value;
|
|
167
167
|
}
|
|
168
168
|
return this.platform.getIndexName(this.name, columnNames, type);
|