@mikro-orm/sql
Advanced tools
@@ -489,6 +489,9 @@ import { DeferMode, EnumType, Type, Utils, } from '@mikro-orm/core'; | ||
| // CHECK: unwrap the `CHECK ((<predicate>))` shell and drop pg-added `::type` casts so the | ||
| // inner predicate matches the user's metadata. EXCLUDE bodies are kept verbatim — the user's | ||
| // `@Check` expression is the full body (see SchemaHelper.createCheck). | ||
| // inner predicate matches the user's metadata. Bare boolean bodies (e.g. a top-level CASE) | ||
| // are emitted as the single-paren `CHECK (<predicate>)` form, which we unwrap too. EXCLUDE | ||
| // bodies are kept verbatim — the user's `@Check` expression is the full body (see | ||
| // SchemaHelper.createCheck). | ||
| const m = /^check \(\((.*)\)\)$/is.exec(check.expression); | ||
| const def = m ? m[1].replace(/\((.*?)\)::\w+/g, '$1') : check.expression; | ||
| const single = m ? null : /^check \((.*)\)$/is.exec(check.expression); | ||
| const def = m ? m[1].replace(/\((.*?)\)::\w+/g, '$1') : single ? single[1] : check.expression; | ||
| ret[key].push({ | ||
@@ -829,3 +832,5 @@ name: check.name, | ||
| const m1 = item.definition?.match(/check \(\(\("?(\w+)"?\)::/i) || item.definition?.match(/check \(\("?(\w+)"? = /i); | ||
| const m2 = item.definition?.match(/\(array\[(.*)]\)/i) || item.definition?.match(/ = (.*)\)/i); | ||
| // the single-value form must compare against a quoted literal (`= 'a'::text`); anything else | ||
| // (e.g. a JSON `->>` extraction like `name = data->>'name'`) is not an enum constraint | ||
| const m2 = item.definition?.match(/\(array\[(.*)]\)/i) || item.definition?.match(/ = ('(?:[^']|'')*'::[\w ]+)\)/i); | ||
| if (item.columnName && m1 && m2) { | ||
@@ -832,0 +837,0 @@ /* v8 ignore next */ |
+2
-2
| { | ||
| "name": "@mikro-orm/sql", | ||
| "version": "7.1.4-dev.0", | ||
| "version": "7.1.4-dev.1", | ||
| "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.4-dev.0" | ||
| "@mikro-orm/core": "7.1.4-dev.1" | ||
| }, | ||
@@ -59,0 +59,0 @@ "engines": { |
1044753
0.05%21903
0.02%