@mikro-orm/sql
Advanced tools
+2
-2
| { | ||
| "name": "@mikro-orm/sql", | ||
| "version": "7.1.5-dev.9", | ||
| "version": "7.1.5-dev.10", | ||
| "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.5-dev.9" | ||
| "@mikro-orm/core": "7.1.5-dev.10" | ||
| }, | ||
@@ -59,0 +59,0 @@ "engines": { |
| import { ReferenceKind, isRaw, } from '@mikro-orm/core'; | ||
| import { DatabaseTable } from './DatabaseTable.js'; | ||
| import { normalizeViewDefinition } from './SchemaHelper.js'; | ||
| import { getTablePartitioning } from './partitioning.js'; | ||
@@ -367,3 +368,3 @@ /** | ||
| if (typeof meta.expression === 'string') { | ||
| return meta.expression; | ||
| return normalizeViewDefinition(meta.expression); | ||
| } | ||
@@ -382,3 +383,3 @@ // Expression is a function, need to evaluate it | ||
| if (typeof result === 'string') { | ||
| return result; | ||
| return normalizeViewDefinition(result); | ||
| } | ||
@@ -385,0 +386,0 @@ /* v8 ignore next */ |
@@ -9,2 +9,13 @@ import { type Connection, type Dictionary, type Options, type Transaction, type RawQueryFragment } from '@mikro-orm/core'; | ||
| export declare function stripStatementNewlines(body: string): string; | ||
| /** | ||
| * Strips SQL line comments and blank lines from a view definition. Comments are dropped by the | ||
| * database on `create view` anyway, and a `--` comment would otherwise comment out the rest of the | ||
| * definition once newlines are collapsed; blank lines act as statement separators in the | ||
| * schema-generator's statement splitter, which would break the view DDL apart. | ||
| * | ||
| * Comment stripping is not string-literal aware, so a `--` inside a string literal (or `a--b` style | ||
| * arithmetic) is treated as a comment — an accepted tradeoff to avoid a full SQL tokenizer. | ||
| * @see https://github.com/mikro-orm/mikro-orm/issues/7875 | ||
| */ | ||
| export declare function normalizeViewDefinition(definition: string): string; | ||
| /** Base class for database-specific schema helpers. Provides SQL generation for DDL operations. */ | ||
@@ -11,0 +22,0 @@ export declare abstract class SchemaHelper { |
@@ -6,2 +6,20 @@ import { isRaw, Utils, } from '@mikro-orm/core'; | ||
| } | ||
| /** | ||
| * Strips SQL line comments and blank lines from a view definition. Comments are dropped by the | ||
| * database on `create view` anyway, and a `--` comment would otherwise comment out the rest of the | ||
| * definition once newlines are collapsed; blank lines act as statement separators in the | ||
| * schema-generator's statement splitter, which would break the view DDL apart. | ||
| * | ||
| * Comment stripping is not string-literal aware, so a `--` inside a string literal (or `a--b` style | ||
| * arithmetic) is treated as a comment — an accepted tradeoff to avoid a full SQL tokenizer. | ||
| * @see https://github.com/mikro-orm/mikro-orm/issues/7875 | ||
| */ | ||
| export function normalizeViewDefinition(definition) { | ||
| return definition | ||
| .replace(/--[^\n]*/g, '') | ||
| .split('\n') | ||
| .filter(line => line.trim() !== '') | ||
| .join('\n') | ||
| .trim(); | ||
| } | ||
| /** Base class for database-specific schema helpers. Provides SQL generation for DDL operations. */ | ||
@@ -8,0 +26,0 @@ export class SchemaHelper { |
@@ -133,3 +133,3 @@ import { CommitOrderCalculator, TableNotFoundException, Utils, } from '@mikro-orm/core'; | ||
| const schema = options?.schema ?? this.config.get('schema', this.platform.getDefaultSchemaName()); | ||
| for (const meta of this.getOrderedMetadata(schema).reverse()) { | ||
| for (const meta of this.getOrderedMetadataForClear(schema).reverse()) { | ||
| try { | ||
@@ -136,0 +136,0 @@ await this.driver |
1046618
0.16%21933
0.14%