@mikro-orm/sql 7.1.3 → 7.1.4-dev.1
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.
|
@@ -486,10 +486,13 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
|
|
|
486
486
|
seen.add(dedupeKey);
|
|
487
487
|
ret[key] ??= [];
|
|
488
488
|
// CHECK: unwrap the `CHECK ((<predicate>))` shell and drop pg-added `::type` casts so the
|
|
489
|
-
// inner predicate matches the user's metadata.
|
|
490
|
-
//
|
|
489
|
+
// inner predicate matches the user's metadata. Bare boolean bodies (e.g. a top-level CASE)
|
|
490
|
+
// are emitted as the single-paren `CHECK (<predicate>)` form, which we unwrap too. EXCLUDE
|
|
491
|
+
// bodies are kept verbatim — the user's `@Check` expression is the full body (see
|
|
492
|
+
// SchemaHelper.createCheck).
|
|
491
493
|
const m = /^check \(\((.*)\)\)$/is.exec(check.expression);
|
|
492
|
-
const
|
|
494
|
+
const single = m ? null : /^check \((.*)\)$/is.exec(check.expression);
|
|
495
|
+
const def = m ? m[1].replace(/\((.*?)\)::\w+/g, '$1') : single ? single[1] : check.expression;
|
|
493
496
|
ret[key].push({
|
|
494
497
|
name: check.name,
|
|
495
498
|
columnName: check.column_name,
|
|
@@ -825,7 +828,9 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
|
|
|
825
828
|
// `CHECK ((("enumTest")::text = ANY ((ARRAY['a'::character varying, 'b'::character varying, 'c'::character varying])::text[])))`
|
|
826
829
|
// `CHECK ((type = 'a'::text))`
|
|
827
830
|
const m1 = item.definition?.match(/check \(\(\("?(\w+)"?\)::/i) || item.definition?.match(/check \(\("?(\w+)"? = /i);
|
|
828
|
-
|
|
831
|
+
// the single-value form must compare against a quoted literal (`= 'a'::text`); anything else
|
|
832
|
+
// (e.g. a JSON `->>` extraction like `name = data->>'name'`) is not an enum constraint
|
|
833
|
+
const m2 = item.definition?.match(/\(array\[(.*)]\)/i) || item.definition?.match(/ = ('(?:[^']|'')*'::[\w ]+)\)/i);
|
|
829
834
|
if (item.columnName && m1 && m2) {
|
|
830
835
|
/* v8 ignore next */
|
|
831
836
|
const parts = m2[1].match(/('(?:[^']|'')*'::\w[\w ]*)/g) ?? m2[1].split(',');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/sql",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.4-dev.1",
|
|
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",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@mikro-orm/core": "^7.1.3"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mikro-orm/core": "7.1.
|
|
56
|
+
"@mikro-orm/core": "7.1.4-dev.1"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|