🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@mikro-orm/sql

Package Overview
Dependencies
Maintainers
1
Versions
700
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mikro-orm/sql - npm Package Compare versions

Comparing version
7.1.7-dev.7
to
7.1.7-dev.8
+7
-0
AbstractSqlPlatform.d.ts

@@ -9,2 +9,3 @@ import { type RawQueryFragment, type Constructor, type EntityManager, type EntityRepository, type IDatabaseDriver, type IsolationLevel, type MikroORM, Platform } from '@mikro-orm/core';

#private;
private static readonly ORDER_BY_DIRECTIONS;
protected readonly schemaHelper?: SchemaHelper;

@@ -51,2 +52,8 @@ usesPivotTable(): boolean;

/**
* `toLowerCase()` folds every `QueryOrder` enum member (and the normalized `QueryOrderNumeric`
* values) onto the six allow-listed directions, so only unknown values are rejected.
* @internal
*/
validateOrderByDirection(direction: string): string;
/**
* Quotes a collation name for use in COLLATE clauses.

@@ -53,0 +60,0 @@ * @internal

+23
-2

@@ -8,2 +8,10 @@ import { isRaw, JsonProperty, Platform, raw, Utils, } from '@mikro-orm/core';

static #JSON_PROPERTY_NAME_RE = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
static ORDER_BY_DIRECTIONS = new Set([
'asc',
'desc',
'asc nulls first',
'asc nulls last',
'desc nulls first',
'desc nulls last',
]);
schemaHelper;

@@ -119,8 +127,21 @@ usesPivotTable() {

getOrderByExpression(column, direction, collation) {
const dir = this.validateOrderByDirection(direction);
if (collation) {
return [`${column} collate ${this.quoteCollation(collation)} ${direction.toLowerCase()}`];
return [`${column} collate ${this.quoteCollation(collation)} ${dir}`];
}
return [`${column} ${direction.toLowerCase()}`];
return [`${column} ${dir}`];
}
/**
* `toLowerCase()` folds every `QueryOrder` enum member (and the normalized `QueryOrderNumeric`
* values) onto the six allow-listed directions, so only unknown values are rejected.
* @internal
*/
validateOrderByDirection(direction) {
const dir = ('' + direction).toLowerCase().trim();
if (!AbstractSqlPlatform.ORDER_BY_DIRECTIONS.has(dir)) {
throw new Error(`Invalid order direction: '${direction}'`);
}
return dir;
}
/**
* Quotes a collation name for use in COLLATE clauses.

@@ -127,0 +148,0 @@ * @internal

+1
-1

@@ -117,3 +117,3 @@ import { QueryOrder, DecimalType, DoubleType, } from '@mikro-orm/core';

const ret = [];
const dir = direction.toLowerCase();
const dir = this.validateOrderByDirection(direction);
const col = collation ? `${column} collate ${this.quoteCollation(collation)}` : column;

@@ -120,0 +120,0 @@ if (dir in this.ORDER_BY_NULLS_TRANSLATE) {

{
"name": "@mikro-orm/sql",
"version": "7.1.7-dev.7",
"version": "7.1.7-dev.8",
"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.7-dev.7"
"@mikro-orm/core": "7.1.7-dev.8"
},

@@ -59,0 +59,0 @@ "engines": {