@mikro-orm/sql 7.1.9-dev.8 → 7.1.9-dev.9

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/sql",
3
- "version": "7.1.9-dev.8",
3
+ "version": "7.1.9-dev.9",
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.8"
54
54
  },
55
55
  "peerDependencies": {
56
- "@mikro-orm/core": "7.1.9-dev.8"
56
+ "@mikro-orm/core": "7.1.9-dev.9"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">= 22.17.0"
@@ -897,9 +897,13 @@ export class SchemaComparator {
897
897
  // lookbehind: only strip a real charset introducer, never an underscore inside a literal like 'a_b'
898
898
  ?.replace(/(?<![\w'])_\w+'(.*?)'/g, '$1')
899
899
  .replace(/!=/g, '<>')
900
- .replace(/in\s*\((.*?)\)/gi, '= any (array[$1])')
900
+ // `\b` keeps this from firing inside identifiers like `min(...)`
901
+ .replace(/\bin\s*\((.*?)\)/gi, '= any (array[$1])')
901
902
  // MySQL normalizes count(*) to count(0)
902
903
  .replace(/\bcount\s*\(\s*0\s*\)/gi, 'count(*)')
904
+ // multi word type names in casts, the generic `::\w+` below only covers single word ones
905
+ // the precision is kept, so `timestamptz(3)` and `timestamp(3) with time zone` leave the same residue
906
+ .replace(/::\s*(?:character\s+varying|bit\s+varying|double\s+precision|(?:timestamp|time)\b(\s*\(\d+\))?(?:\s+with(?:out)?\s+time\s+zone)?)/gi, '$1')
903
907
  // Remove quotes first so we can process identifiers
904
908
  .replace(/['"`]/g, '')
905
909
  // MySQL adds table/alias prefixes to columns (e.g., a.name or table_name.column vs just column)
@@ -907,6 +911,10 @@ export class SchemaComparator {
907
911
  .replace(/\b\w+\.(\w+)/g, '$1')
908
912
  // Normalize JOIN syntax: inner join -> join (equivalent in SQL)
909
913
  .replace(/\binner\s+join\b/gi, 'join')
914
+ // PostgreSQL names an unaliased bare function call after the function itself,
915
+ // so `max(created_at)` comes back as `max(created_at) AS max`
916
+ // the lookahead skips table function column alias lists like `unnest(a) AS unnest(c)`, which are meaningful
917
+ .replace(/\b(\w+)\s*\(((?:[^()]|\([^()]*\))*)\)\s+as\s+\1\b(?!\s*\()/gi, '$1($2)')
910
918
  // Remove redundant column aliases like `title AS title` -> `title`
911
919
  .replace(/\b(\w+)\s+as\s+\1\b/gi, '$1')
912
920
  // Remove AS keyword (optional in SQL, MySQL may add/remove it)