@mikro-orm/sql 7.1.7 → 7.2.0-dev.0
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
CHANGED
|
@@ -6,7 +6,6 @@ import { NativeQueryBuilder } from './query/NativeQueryBuilder.js';
|
|
|
6
6
|
/** Base class for SQL database platforms, providing SQL generation and quoting utilities. */
|
|
7
7
|
export declare abstract class AbstractSqlPlatform extends Platform {
|
|
8
8
|
#private;
|
|
9
|
-
private static readonly ORDER_BY_DIRECTIONS;
|
|
10
9
|
protected readonly schemaHelper?: SchemaHelper;
|
|
11
10
|
usesPivotTable(): boolean;
|
|
12
11
|
indexForeignKeys(): boolean;
|
|
@@ -47,12 +46,6 @@ export declare abstract class AbstractSqlPlatform extends Platform {
|
|
|
47
46
|
* @internal
|
|
48
47
|
*/
|
|
49
48
|
getOrderByExpression(column: string, direction: string, collation?: string): string[];
|
|
50
|
-
/**
|
|
51
|
-
* `toLowerCase()` folds every `QueryOrder` enum member (and the normalized `QueryOrderNumeric`
|
|
52
|
-
* values) onto the six allow-listed directions, so only unknown values are rejected.
|
|
53
|
-
* @internal
|
|
54
|
-
*/
|
|
55
|
-
validateOrderByDirection(direction: string): string;
|
|
56
49
|
/**
|
|
57
50
|
* Quotes a collation name for use in COLLATE clauses.
|
|
58
51
|
* @internal
|
package/AbstractSqlPlatform.js
CHANGED
|
@@ -5,14 +5,6 @@ import { NativeQueryBuilder } from './query/NativeQueryBuilder.js';
|
|
|
5
5
|
/** Base class for SQL database platforms, providing SQL generation and quoting utilities. */
|
|
6
6
|
export class AbstractSqlPlatform extends Platform {
|
|
7
7
|
static #JSON_PROPERTY_NAME_RE = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
8
|
-
static ORDER_BY_DIRECTIONS = new Set([
|
|
9
|
-
'asc',
|
|
10
|
-
'desc',
|
|
11
|
-
'asc nulls first',
|
|
12
|
-
'asc nulls last',
|
|
13
|
-
'desc nulls first',
|
|
14
|
-
'desc nulls last',
|
|
15
|
-
]);
|
|
16
8
|
schemaHelper;
|
|
17
9
|
usesPivotTable() {
|
|
18
10
|
return true;
|
|
@@ -123,23 +115,10 @@ export class AbstractSqlPlatform extends Platform {
|
|
|
123
115
|
* @internal
|
|
124
116
|
*/
|
|
125
117
|
getOrderByExpression(column, direction, collation) {
|
|
126
|
-
const dir = this.validateOrderByDirection(direction);
|
|
127
118
|
if (collation) {
|
|
128
|
-
return [`${column} collate ${this.quoteCollation(collation)} ${
|
|
119
|
+
return [`${column} collate ${this.quoteCollation(collation)} ${direction.toLowerCase()}`];
|
|
129
120
|
}
|
|
130
|
-
return [`${column} ${
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* `toLowerCase()` folds every `QueryOrder` enum member (and the normalized `QueryOrderNumeric`
|
|
134
|
-
* values) onto the six allow-listed directions, so only unknown values are rejected.
|
|
135
|
-
* @internal
|
|
136
|
-
*/
|
|
137
|
-
validateOrderByDirection(direction) {
|
|
138
|
-
const dir = ('' + direction).toLowerCase().trim();
|
|
139
|
-
if (!AbstractSqlPlatform.ORDER_BY_DIRECTIONS.has(dir)) {
|
|
140
|
-
throw new Error(`Invalid order direction: '${direction}'`);
|
|
141
|
-
}
|
|
142
|
-
return dir;
|
|
121
|
+
return [`${column} ${direction.toLowerCase()}`];
|
|
143
122
|
}
|
|
144
123
|
/**
|
|
145
124
|
* Quotes a collation name for use in COLLATE clauses.
|
|
@@ -114,7 +114,7 @@ export class BaseMySqlPlatform extends AbstractSqlPlatform {
|
|
|
114
114
|
}
|
|
115
115
|
getOrderByExpression(column, direction, collation) {
|
|
116
116
|
const ret = [];
|
|
117
|
-
const dir =
|
|
117
|
+
const dir = direction.toLowerCase();
|
|
118
118
|
const col = collation ? `${column} collate ${this.quoteCollation(collation)}` : column;
|
|
119
119
|
if (dir in this.ORDER_BY_NULLS_TRANSLATE) {
|
|
120
120
|
ret.push(`${col} ${this.ORDER_BY_NULLS_TRANSLATE[dir]}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/sql",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.0-dev.0",
|
|
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",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"kysely": "0.29.3"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@mikro-orm/core": "^7.1.
|
|
53
|
+
"@mikro-orm/core": "^7.1.6"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mikro-orm/core": "7.
|
|
56
|
+
"@mikro-orm/core": "7.2.0-dev.0"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|