@mikro-orm/mssql 7.0.0-dev.14 → 7.0.0-dev.15

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.
@@ -1,4 +1,4 @@
1
- import { AbstractSqlPlatform, type EntityMetadata, type IDatabaseDriver, type EntityManager, type MikroORM, Type, type Primary, type IPrimaryKey, MsSqlNativeQueryBuilder } from '@mikro-orm/knex';
1
+ import { AbstractSqlPlatform, type EntityMetadata, type IDatabaseDriver, type EntityManager, type MikroORM, Type, type Primary, type IPrimaryKey, QueryOrder, MsSqlNativeQueryBuilder } from '@mikro-orm/knex';
2
2
  import { MsSqlSchemaHelper } from './MsSqlSchemaHelper.js';
3
3
  import { MsSqlExceptionConverter } from './MsSqlExceptionConverter.js';
4
4
  import { MsSqlSchemaGenerator } from './MsSqlSchemaGenerator.js';
@@ -59,5 +59,6 @@ export declare class MsSqlPlatform extends AbstractSqlPlatform {
59
59
  escape(value: any): string;
60
60
  getSchemaGenerator(driver: IDatabaseDriver, em?: EntityManager): MsSqlSchemaGenerator;
61
61
  allowsComparingTuples(): boolean;
62
+ getOrderByExpression(column: string, direction: QueryOrder): string[];
62
63
  getDefaultClientUrl(): string;
63
64
  }
package/MsSqlPlatform.js CHANGED
@@ -1,4 +1,4 @@
1
- import { AbstractSqlPlatform, raw, Type, Utils, ALIAS_REPLACEMENT, DoubleType, FloatType, RawQueryFragment, MsSqlNativeQueryBuilder, } from '@mikro-orm/knex';
1
+ import { AbstractSqlPlatform, raw, Type, Utils, ALIAS_REPLACEMENT, DoubleType, FloatType, QueryOrder, RawQueryFragment, MsSqlNativeQueryBuilder, } from '@mikro-orm/knex';
2
2
  // @ts-expect-error no types available
3
3
  import SqlString from 'tsqlstring';
4
4
  import { MsSqlSchemaHelper } from './MsSqlSchemaHelper.js';
@@ -196,6 +196,20 @@ export class MsSqlPlatform extends AbstractSqlPlatform {
196
196
  allowsComparingTuples() {
197
197
  return false;
198
198
  }
199
+ getOrderByExpression(column, direction) {
200
+ switch (direction.toUpperCase()) {
201
+ case QueryOrder.ASC_NULLS_FIRST:
202
+ return [`case when ${column} is null then 0 else 1 end, ${column} asc`];
203
+ case QueryOrder.ASC_NULLS_LAST:
204
+ return [`case when ${column} is null then 1 else 0 end, ${column} asc`];
205
+ case QueryOrder.DESC_NULLS_FIRST:
206
+ return [`case when ${column} is null then 0 else 1 end, ${column} desc`];
207
+ case QueryOrder.DESC_NULLS_LAST:
208
+ return [`case when ${column} is null then 1 else 0 end, ${column} desc`];
209
+ default:
210
+ return [`${column} ${direction.toLowerCase()}`];
211
+ }
212
+ }
199
213
  getDefaultClientUrl() {
200
214
  return 'mssql://sa@localhost:1433';
201
215
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mikro-orm/mssql",
3
3
  "type": "module",
4
- "version": "7.0.0-dev.14",
4
+ "version": "7.0.0-dev.15",
5
5
  "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.",
6
6
  "exports": {
7
7
  "./package.json": "./package.json",
@@ -50,17 +50,17 @@
50
50
  "access": "public"
51
51
  },
52
52
  "dependencies": {
53
- "@mikro-orm/knex": "7.0.0-dev.14",
53
+ "@mikro-orm/knex": "7.0.0-dev.15",
54
54
  "tarn": "3.0.2",
55
55
  "tedious": "19.0.0",
56
56
  "tsqlstring": "1.0.1"
57
57
  },
58
58
  "devDependencies": {
59
- "@mikro-orm/core": "^6.4.13",
59
+ "@mikro-orm/core": "^6.4.14",
60
60
  "kysely": "0.28.2"
61
61
  },
62
62
  "peerDependencies": {
63
- "@mikro-orm/core": "7.0.0-dev.14",
63
+ "@mikro-orm/core": "7.0.0-dev.15",
64
64
  "kysely": "*"
65
65
  }
66
66
  }