@absolutejs/auth 0.56.7 → 0.56.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.
@@ -539,6 +539,9 @@ var SQL = class SQL2 {
539
539
  this.decoder = typeof decoder === "function" ? { mapFromDriverValue: decoder } : decoder;
540
540
  return this;
541
541
  }
542
+ nullable() {
543
+ return this;
544
+ }
542
545
  inlineParams() {
543
546
  this.shouldInlineParams = true;
544
547
  return this;
@@ -724,9 +727,10 @@ function fillPlaceholders(params, values) {
724
727
  if (is(p, Param) && is(p.value, Placeholder)) {
725
728
  if (!(p.value.name in values))
726
729
  throw new Error(`No value for placeholder "${p.value.name}" was provided`);
727
- if (values[p.value.name] === null)
728
- return values[p.value.name];
729
- const mapped = p.encoder.mapToDriverValue.isNoop ? values[p.value.name] : p.encoder.mapToDriverValue(values[p.value.name]);
730
+ const value = values[p.value.name];
731
+ if (value === null)
732
+ return value;
733
+ const mapped = p.encoder.mapToDriverValue.isNoop ? value : p.encoder.mapToDriverValue(value);
730
734
  return p.codec ? p.codec(mapped) : mapped;
731
735
  }
732
736
  return p;
@@ -1096,6 +1100,9 @@ var PgColumn = class extends Column {
1096
1100
  }
1097
1101
  return this;
1098
1102
  }
1103
+ shouldDisableInsert() {
1104
+ return this.config.generatedIdentity !== undefined && this.config.generatedIdentity.type !== "byDefault" || this.config.generated !== undefined && this.config.generated.type !== "byDefault";
1105
+ }
1099
1106
  mapArrayElements(value, mapper, depth) {
1100
1107
  if (depth > 0 && Array.isArray(value))
1101
1108
  return value.map((v) => v === null ? null : this.mapArrayElements(v, mapper, depth - 1));
@@ -1361,20 +1368,59 @@ function orderSelectedFields2(fields, pathPrefix, codecs) {
1361
1368
  path: newPath,
1362
1369
  field,
1363
1370
  codec: codecs?.get(field, "normalize"),
1364
- arrayDimensions: field.dimensions
1371
+ arrayDimensions: field.dimensions,
1372
+ column: field
1365
1373
  });
1366
- else if (is(field, Column) || is(field, SQL) || is(field, SQL.Aliased) || is(field, Subquery))
1367
- result.push({
1374
+ else if (is(field, SQL) || is(field, SQL.Aliased)) {
1375
+ const col = getColumnFromDecoder2(field);
1376
+ result.push(col ? {
1377
+ path: newPath,
1378
+ field,
1379
+ codec: codecs?.get(col, "normalize"),
1380
+ arrayDimensions: col.dimensions,
1381
+ column: col
1382
+ } : {
1383
+ path: newPath,
1384
+ field
1385
+ });
1386
+ } else if (is(field, Subquery)) {
1387
+ let column;
1388
+ const entry = Object.values(field._.selectedFields)[0];
1389
+ let fieldDecoder;
1390
+ if (is(entry, Column)) {
1391
+ column = entry;
1392
+ fieldDecoder = entry;
1393
+ } else if (is(entry, SQL)) {
1394
+ column = getColumnFromDecoder2(entry);
1395
+ fieldDecoder = entry.decoder;
1396
+ } else {
1397
+ column = getColumnFromDecoder2(entry);
1398
+ fieldDecoder = entry.sql.decoder;
1399
+ }
1400
+ if (fieldDecoder)
1401
+ field._.sql.decoder = fieldDecoder;
1402
+ result.push(column ? {
1403
+ path: newPath,
1404
+ field,
1405
+ codec: codecs?.get(column, "normalize"),
1406
+ arrayDimensions: column.dimensions,
1407
+ column
1408
+ } : {
1368
1409
  path: newPath,
1369
1410
  field
1370
1411
  });
1371
- else if (is(field, Table))
1412
+ } else if (is(field, Table))
1372
1413
  result.push(...orderSelectedFields2(field[Table.Symbol.Columns], newPath, codecs));
1373
1414
  else
1374
1415
  result.push(...orderSelectedFields2(field, newPath, codecs));
1375
1416
  return result;
1376
1417
  }, []);
1377
1418
  }
1419
+ function getColumnFromDecoder2(source) {
1420
+ const query = source.getSQL();
1421
+ if (is(query.decoder, Column))
1422
+ return query.decoder;
1423
+ }
1378
1424
  function haveSameKeys2(left, right) {
1379
1425
  const leftKeys = Object.keys(left);
1380
1426
  const rightKeys = Object.keys(right);
@@ -1518,481 +1564,169 @@ var PgBoolean = class extends PgColumn {
1518
1564
  function boolean(name2) {
1519
1565
  return new PgBooleanBuilder(name2 ?? "");
1520
1566
  }
1521
- // node_modules/drizzle-orm/pg-core/columns/double-precision.js
1522
- var PgDoublePrecisionBuilder = class extends PgColumnBuilder {
1523
- static [entityKind] = "PgDoublePrecisionBuilder";
1524
- constructor(name2) {
1525
- super(name2, "number double", "PgDoublePrecision");
1526
- }
1527
- build(table) {
1528
- return new PgDoublePrecision(table, this.config);
1529
- }
1530
- };
1531
- var PgDoublePrecision = class extends PgColumn {
1532
- static [entityKind] = "PgDoublePrecision";
1533
- codec = "float8";
1534
- getSQLType() {
1535
- return "double precision";
1567
+ // node_modules/drizzle-orm/pg-core/array.js
1568
+ function parsePgArrayValue(arrayString, startFrom, inQuotes) {
1569
+ for (let i = startFrom;i < arrayString.length; i++) {
1570
+ const char = arrayString[i];
1571
+ if (char === "\\") {
1572
+ i++;
1573
+ continue;
1574
+ }
1575
+ if (char === '"')
1576
+ return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i + 1];
1577
+ if (inQuotes)
1578
+ continue;
1579
+ if (char === "," || char === "}")
1580
+ return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i];
1536
1581
  }
1537
- };
1538
- function doublePrecision(name2) {
1539
- return new PgDoublePrecisionBuilder(name2 ?? "");
1582
+ return [arrayString.slice(startFrom).replace(/\\/g, ""), arrayString.length];
1540
1583
  }
1541
- // node_modules/drizzle-orm/pg-core/columns/integer.js
1542
- var PgIntegerBuilder = class extends PgIntColumnBuilder {
1543
- static [entityKind] = "PgIntegerBuilder";
1544
- constructor(name2) {
1545
- super(name2, "number int32", "PgInteger");
1546
- }
1547
- build(table) {
1548
- return new PgInteger(table, this.config);
1549
- }
1550
- };
1551
- var PgInteger = class extends PgColumn {
1552
- static [entityKind] = "PgInteger";
1553
- codec = "int";
1554
- getSQLType() {
1555
- return "integer";
1584
+ function parsePgNestedArray(arrayString, startFrom = 0) {
1585
+ const result = [];
1586
+ let i = startFrom;
1587
+ let lastCharIsComma = false;
1588
+ while (i < arrayString.length) {
1589
+ const char = arrayString[i];
1590
+ if (char === ",") {
1591
+ if (lastCharIsComma || i === startFrom)
1592
+ result.push("");
1593
+ lastCharIsComma = true;
1594
+ i++;
1595
+ continue;
1596
+ }
1597
+ lastCharIsComma = false;
1598
+ if (char === "\\") {
1599
+ i += 2;
1600
+ continue;
1601
+ }
1602
+ if (char === '"') {
1603
+ const [value2, startFrom2] = parsePgArrayValue(arrayString, i + 1, true);
1604
+ result.push(value2);
1605
+ i = startFrom2;
1606
+ continue;
1607
+ }
1608
+ if (char === "}")
1609
+ return [result, i + 1];
1610
+ if (char === "{") {
1611
+ const [value2, startFrom2] = parsePgNestedArray(arrayString, i + 1);
1612
+ result.push(value2);
1613
+ i = startFrom2;
1614
+ continue;
1615
+ }
1616
+ const [value, newStartFrom] = parsePgArrayValue(arrayString, i, false);
1617
+ result.push(value);
1618
+ i = newStartFrom;
1556
1619
  }
1557
- };
1558
- function integer(name2) {
1559
- return new PgIntegerBuilder(name2 ?? "");
1620
+ return [result, i];
1560
1621
  }
1561
- // node_modules/drizzle-orm/pg-core/columns/jsonb.js
1562
- var PgJsonbBuilder = class extends PgColumnBuilder {
1563
- static [entityKind] = "PgJsonbBuilder";
1564
- constructor(name2) {
1565
- super(name2, "object json", "PgJsonb");
1566
- }
1567
- build(table) {
1568
- return new PgJsonb(table, this.config);
1569
- }
1570
- };
1571
- var PgJsonb = class extends PgColumn {
1572
- static [entityKind] = "PgJsonb";
1573
- codec = "jsonb";
1574
- constructor(table, config) {
1575
- super(table, config);
1576
- }
1577
- getSQLType() {
1578
- return "jsonb";
1579
- }
1580
- };
1581
- function jsonb(name2) {
1582
- return new PgJsonbBuilder(name2 ?? "");
1622
+ function parsePgArray(arrayString) {
1623
+ const [result] = parsePgNestedArray(arrayString, 1);
1624
+ return result;
1583
1625
  }
1584
- // node_modules/drizzle-orm/pg-core/columns/smallint.js
1585
- var PgSmallIntBuilder = class extends PgIntColumnBuilder {
1586
- static [entityKind] = "PgSmallIntBuilder";
1587
- constructor(name2) {
1588
- super(name2, "number int16", "PgSmallInt");
1626
+ function makePgArray(array) {
1627
+ return `{${array.map((item) => {
1628
+ if (Array.isArray(item))
1629
+ return makePgArray(item);
1630
+ if (typeof item === "string")
1631
+ return `"${item.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
1632
+ return `${item}`;
1633
+ }).join(",")}}`;
1634
+ }
1635
+
1636
+ // node_modules/drizzle-orm/pg-core/columns/postgis_extension/utils.js
1637
+ function hexToBytes(hex) {
1638
+ const bytes = [];
1639
+ for (let c = 0;c < hex.length; c += 2)
1640
+ bytes.push(Number.parseInt(hex.slice(c, c + 2), 16));
1641
+ return new Uint8Array(bytes);
1642
+ }
1643
+ function bytesToFloat64(bytes, offset) {
1644
+ const buffer = /* @__PURE__ */ new ArrayBuffer(8);
1645
+ const view = new DataView(buffer);
1646
+ for (let i = 0;i < 8; i++)
1647
+ view.setUint8(i, bytes[offset + i]);
1648
+ return view.getFloat64(0, true);
1649
+ }
1650
+ function parseEWKB(hex) {
1651
+ const bytes = hexToBytes(hex);
1652
+ let offset = 0;
1653
+ const byteOrder = bytes[offset];
1654
+ offset += 1;
1655
+ const view = new DataView(bytes.buffer);
1656
+ const geomType = view.getUint32(offset, byteOrder === 1);
1657
+ offset += 4;
1658
+ let srid;
1659
+ if (geomType & 536870912) {
1660
+ srid = view.getUint32(offset, byteOrder === 1);
1661
+ offset += 4;
1589
1662
  }
1590
- build(table) {
1591
- return new PgSmallInt(table, this.config);
1663
+ if ((geomType & 65535) === 1) {
1664
+ const x = bytesToFloat64(bytes, offset);
1665
+ offset += 8;
1666
+ const y = bytesToFloat64(bytes, offset);
1667
+ offset += 8;
1668
+ return {
1669
+ srid,
1670
+ point: [x, y]
1671
+ };
1592
1672
  }
1673
+ throw new Error("Unsupported geometry type");
1674
+ }
1675
+
1676
+ // node_modules/drizzle-orm/codecs.js
1677
+ var noopCodecs = {};
1678
+ var arrayToItemTypeCodecNameMap = {
1679
+ cast: "cast",
1680
+ castArray: "cast",
1681
+ castInJson: "castInJson",
1682
+ castArrayInJson: "castInJson",
1683
+ castParam: "castParam",
1684
+ castArrayParam: "castParam",
1685
+ normalize: "normalize",
1686
+ normalizeArray: "normalize",
1687
+ normalizeInJson: "normalizeInJson",
1688
+ normalizeArrayInJson: "normalizeInJson",
1689
+ normalizeParam: "normalizeParam",
1690
+ normalizeParamArray: "normalizeParam"
1593
1691
  };
1594
- var PgSmallInt = class extends PgColumn {
1595
- static [entityKind] = "PgSmallInt";
1596
- codec = "smallint";
1597
- getSQLType() {
1598
- return "smallint";
1599
- }
1692
+ var itemToArrayTypeCodecNameMap = {
1693
+ cast: "castArray",
1694
+ castArray: "castArray",
1695
+ castInJson: "castArrayInJson",
1696
+ castArrayInJson: "castArrayInJson",
1697
+ castParam: "castArrayParam",
1698
+ castArrayParam: "castArrayParam",
1699
+ normalize: "normalizeArray",
1700
+ normalizeArray: "normalizeArray",
1701
+ normalizeInJson: "normalizeArrayInJson",
1702
+ normalizeArrayInJson: "normalizeArrayInJson",
1703
+ normalizeParam: "normalizeParamArray",
1704
+ normalizeParamArray: "normalizeParamArray"
1600
1705
  };
1601
- function smallint(name2) {
1602
- return new PgSmallIntBuilder(name2 ?? "");
1603
- }
1604
- // node_modules/drizzle-orm/pg-core/columns/text.js
1605
- var PgTextBuilder = class extends PgColumnBuilder {
1606
- static [entityKind] = "PgTextBuilder";
1607
- constructor(name2, config) {
1608
- super(name2, config.enum?.length ? "string enum" : "string", "PgText");
1609
- this.config.enumValues = config.enum;
1610
- }
1611
- build(table) {
1612
- return new PgText(table, this.config, this.config.enumValues);
1706
+ var CodecsCollection = class {
1707
+ static [entityKind] = "CodecsCollection";
1708
+ constructor(resolveTypes, codecs = noopCodecs) {
1709
+ this.resolveTypes = resolveTypes;
1710
+ this.codecs = codecs;
1613
1711
  }
1614
- };
1615
- var PgText = class extends PgColumn {
1616
- static [entityKind] = "PgText";
1617
- enumValues;
1618
- codec = "text";
1619
- constructor(table, config, enumValues) {
1620
- super(table, config);
1621
- this.enumValues = enumValues;
1712
+ get(column, type, override) {
1713
+ const sqlType = override ?? column.codec;
1714
+ if (!sqlType)
1715
+ return;
1716
+ const codecType = column.dimensions ? itemToArrayTypeCodecNameMap[type] : arrayToItemTypeCodecNameMap[type];
1717
+ return this.codecs[sqlType]?.[codecType];
1622
1718
  }
1623
- getSQLType() {
1624
- return "text";
1625
- }
1626
- };
1627
- function text(a, b = {}) {
1628
- const { name: name2, config } = getColumnNameAndConfig2(a, b);
1629
- return new PgTextBuilder(name2, config);
1630
- }
1631
- // node_modules/drizzle-orm/pg-core/columns/date.common.js
1632
- var PgDateColumnBuilder = class extends PgColumnBuilder {
1633
- static [entityKind] = "PgDateColumnBaseBuilder";
1634
- defaultNow() {
1635
- return this.default(sql`now()`);
1636
- }
1637
- };
1638
-
1639
- // node_modules/drizzle-orm/pg-core/columns/timestamp.js
1640
- var PgTimestampBuilder = class extends PgDateColumnBuilder {
1641
- static [entityKind] = "PgTimestampBuilder";
1642
- constructor(name2, withTimezone, precision) {
1643
- super(name2, "object date", "PgTimestamp");
1644
- this.config.withTimezone = withTimezone;
1645
- this.config.precision = precision;
1646
- }
1647
- build(table) {
1648
- return new PgTimestamp(table, this.config);
1649
- }
1650
- };
1651
- var PgTimestamp = class extends PgColumn {
1652
- static [entityKind] = "PgTimestamp";
1653
- codec;
1654
- withTimezone;
1655
- precision;
1656
- constructor(table, config) {
1657
- super(table, config);
1658
- this.withTimezone = config.withTimezone;
1659
- this.precision = config.precision;
1660
- this.codec = this.withTimezone ? "timestamptz" : "timestamp";
1661
- }
1662
- getSQLType() {
1663
- return `timestamp${this.precision === undefined ? "" : ` (${this.precision})`}${this.withTimezone ? " with time zone" : ""}`;
1664
- }
1665
- mapToDriverValue = (value) => {
1666
- if (typeof value === "string")
1667
- return value;
1668
- return value.toISOString();
1669
- };
1670
- };
1671
- var PgTimestampStringBuilder = class extends PgDateColumnBuilder {
1672
- static [entityKind] = "PgTimestampStringBuilder";
1673
- constructor(name2, withTimezone, precision) {
1674
- super(name2, "string timestamp", "PgTimestampString");
1675
- this.config.withTimezone = withTimezone;
1676
- this.config.precision = precision;
1677
- }
1678
- build(table) {
1679
- return new PgTimestampString(table, this.config);
1680
- }
1681
- };
1682
- var PgTimestampString = class extends PgColumn {
1683
- static [entityKind] = "PgTimestampString";
1684
- codec;
1685
- withTimezone;
1686
- precision;
1687
- constructor(table, config) {
1688
- super(table, config);
1689
- this.withTimezone = config.withTimezone;
1690
- this.precision = config.precision;
1691
- this.codec = this.withTimezone ? "timestamptz:string" : "timestamp:string";
1692
- }
1693
- getSQLType() {
1694
- return `timestamp${this.precision === undefined ? "" : `(${this.precision})`}${this.withTimezone ? " with time zone" : ""}`;
1695
- }
1696
- mapToDriverValue = (value) => {
1697
- if (typeof value === "string")
1698
- return value;
1699
- return value.toISOString();
1700
- };
1701
- };
1702
- function timestamp(a, b = {}) {
1703
- const { name: name2, config } = getColumnNameAndConfig2(a, b);
1704
- if (config?.mode === "string")
1705
- return new PgTimestampStringBuilder(name2, config.withTimezone ?? false, config.precision);
1706
- return new PgTimestampBuilder(name2, config?.withTimezone ?? false, config?.precision);
1707
- }
1708
- // node_modules/drizzle-orm/pg-core/columns/varchar.js
1709
- var PgVarcharBuilder = class extends PgColumnBuilder {
1710
- static [entityKind] = "PgVarcharBuilder";
1711
- constructor(name2, config) {
1712
- super(name2, config.enum?.length ? "string enum" : "string", "PgVarchar");
1713
- this.config.length = config.length;
1714
- this.config.enumValues = config.enum;
1715
- }
1716
- build(table) {
1717
- return new PgVarchar(table, this.config);
1718
- }
1719
- };
1720
- var PgVarchar = class extends PgColumn {
1721
- static [entityKind] = "PgVarchar";
1722
- codec = "varchar";
1723
- enumValues;
1724
- constructor(table, config) {
1725
- super(table, config);
1726
- this.enumValues = config.enumValues;
1727
- }
1728
- getSQLType() {
1729
- return this.length === undefined ? `varchar` : `varchar(${this.length})`;
1730
- }
1731
- };
1732
- function varchar(a, b = {}) {
1733
- const { name: name2, config } = getColumnNameAndConfig2(a, b);
1734
- return new PgVarcharBuilder(name2, config);
1735
- }
1736
- // node_modules/drizzle-orm/pg-core/columns/bigserial.js
1737
- var PgBigSerial53Builder = class extends PgColumnBuilder {
1738
- static [entityKind] = "PgBigSerial53Builder";
1739
- constructor(name2) {
1740
- super(name2, "number int53", "PgBigSerial53");
1741
- this.config.hasDefault = true;
1742
- this.config.notNull = true;
1743
- }
1744
- build(table) {
1745
- return new PgBigSerial53(table, this.config);
1746
- }
1747
- };
1748
- var PgBigSerial53 = class extends PgColumn {
1749
- static [entityKind] = "PgBigSerial53";
1750
- codec = "bigserial:number";
1751
- getSQLType() {
1752
- return "bigserial";
1753
- }
1754
- };
1755
- var PgBigSerial64Builder = class extends PgColumnBuilder {
1756
- static [entityKind] = "PgBigSerial64Builder";
1757
- constructor(name2) {
1758
- super(name2, "bigint int64", "PgBigSerial64");
1759
- this.config.hasDefault = true;
1760
- this.config.notNull = true;
1761
- }
1762
- build(table) {
1763
- return new PgBigSerial64(table, this.config);
1764
- }
1765
- };
1766
- var PgBigSerial64 = class extends PgColumn {
1767
- static [entityKind] = "PgBigSerial64";
1768
- codec = "bigserial";
1769
- getSQLType() {
1770
- return "bigserial";
1771
- }
1772
- };
1773
- function bigserial(a, b) {
1774
- const { name: name2, config } = getColumnNameAndConfig2(a, b);
1775
- if (config.mode === "number")
1776
- return new PgBigSerial53Builder(name2);
1777
- return new PgBigSerial64Builder(name2);
1778
- }
1779
-
1780
- // node_modules/drizzle-orm/pg-core/columns/char.js
1781
- var PgCharBuilder = class extends PgColumnBuilder {
1782
- static [entityKind] = "PgCharBuilder";
1783
- constructor(name2, config) {
1784
- super(name2, config.enum?.length ? "string enum" : "string", "PgChar");
1785
- this.config.length = config.length ?? 1;
1786
- this.config.setLength = config.length !== undefined;
1787
- this.config.enumValues = config.enum;
1788
- }
1789
- build(table) {
1790
- return new PgChar(table, this.config);
1791
- }
1792
- };
1793
- var PgChar = class extends PgColumn {
1794
- static [entityKind] = "PgChar";
1795
- codec = "char";
1796
- enumValues;
1797
- setLength;
1798
- constructor(table, config) {
1799
- super(table, config);
1800
- this.enumValues = config.enumValues;
1801
- this.setLength = config.setLength;
1802
- }
1803
- getSQLType() {
1804
- return this.setLength ? `char(${this.length})` : `char`;
1805
- }
1806
- };
1807
- function char(a, b = {}) {
1808
- const { name: name2, config } = getColumnNameAndConfig2(a, b);
1809
- return new PgCharBuilder(name2, config);
1810
- }
1811
-
1812
- // node_modules/drizzle-orm/pg-core/columns/cidr.js
1813
- var PgCidrBuilder = class extends PgColumnBuilder {
1814
- static [entityKind] = "PgCidrBuilder";
1815
- constructor(name2) {
1816
- super(name2, "string cidr", "PgCidr");
1817
- }
1818
- build(table) {
1819
- return new PgCidr(table, this.config);
1820
- }
1821
- };
1822
- var PgCidr = class extends PgColumn {
1823
- static [entityKind] = "PgCidr";
1824
- codec = "cidr";
1825
- getSQLType() {
1826
- return "cidr";
1827
- }
1828
- };
1829
- function cidr(name2) {
1830
- return new PgCidrBuilder(name2 ?? "");
1831
- }
1832
-
1833
- // node_modules/drizzle-orm/pg-core/array.js
1834
- function parsePgArrayValue(arrayString, startFrom, inQuotes) {
1835
- for (let i = startFrom;i < arrayString.length; i++) {
1836
- const char2 = arrayString[i];
1837
- if (char2 === "\\") {
1838
- i++;
1839
- continue;
1840
- }
1841
- if (char2 === '"')
1842
- return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i + 1];
1843
- if (inQuotes)
1844
- continue;
1845
- if (char2 === "," || char2 === "}")
1846
- return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i];
1847
- }
1848
- return [arrayString.slice(startFrom).replace(/\\/g, ""), arrayString.length];
1849
- }
1850
- function parsePgNestedArray(arrayString, startFrom = 0) {
1851
- const result = [];
1852
- let i = startFrom;
1853
- let lastCharIsComma = false;
1854
- while (i < arrayString.length) {
1855
- const char2 = arrayString[i];
1856
- if (char2 === ",") {
1857
- if (lastCharIsComma || i === startFrom)
1858
- result.push("");
1859
- lastCharIsComma = true;
1860
- i++;
1861
- continue;
1862
- }
1863
- lastCharIsComma = false;
1864
- if (char2 === "\\") {
1865
- i += 2;
1866
- continue;
1867
- }
1868
- if (char2 === '"') {
1869
- const [value2, startFrom2] = parsePgArrayValue(arrayString, i + 1, true);
1870
- result.push(value2);
1871
- i = startFrom2;
1872
- continue;
1873
- }
1874
- if (char2 === "}")
1875
- return [result, i + 1];
1876
- if (char2 === "{") {
1877
- const [value2, startFrom2] = parsePgNestedArray(arrayString, i + 1);
1878
- result.push(value2);
1879
- i = startFrom2;
1880
- continue;
1881
- }
1882
- const [value, newStartFrom] = parsePgArrayValue(arrayString, i, false);
1883
- result.push(value);
1884
- i = newStartFrom;
1885
- }
1886
- return [result, i];
1887
- }
1888
- function parsePgArray(arrayString) {
1889
- const [result] = parsePgNestedArray(arrayString, 1);
1890
- return result;
1891
- }
1892
- function makePgArray(array) {
1893
- return `{${array.map((item) => {
1894
- if (Array.isArray(item))
1895
- return makePgArray(item);
1896
- if (typeof item === "string")
1897
- return `"${item.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
1898
- return `${item}`;
1899
- }).join(",")}}`;
1900
- }
1901
-
1902
- // node_modules/drizzle-orm/pg-core/columns/postgis_extension/utils.js
1903
- function hexToBytes(hex) {
1904
- const bytes = [];
1905
- for (let c = 0;c < hex.length; c += 2)
1906
- bytes.push(Number.parseInt(hex.slice(c, c + 2), 16));
1907
- return new Uint8Array(bytes);
1908
- }
1909
- function bytesToFloat64(bytes, offset) {
1910
- const buffer = /* @__PURE__ */ new ArrayBuffer(8);
1911
- const view = new DataView(buffer);
1912
- for (let i = 0;i < 8; i++)
1913
- view.setUint8(i, bytes[offset + i]);
1914
- return view.getFloat64(0, true);
1915
- }
1916
- function parseEWKB(hex) {
1917
- const bytes = hexToBytes(hex);
1918
- let offset = 0;
1919
- const byteOrder = bytes[offset];
1920
- offset += 1;
1921
- const view = new DataView(bytes.buffer);
1922
- const geomType = view.getUint32(offset, byteOrder === 1);
1923
- offset += 4;
1924
- let srid;
1925
- if (geomType & 536870912) {
1926
- srid = view.getUint32(offset, byteOrder === 1);
1927
- offset += 4;
1928
- }
1929
- if ((geomType & 65535) === 1) {
1930
- const x = bytesToFloat64(bytes, offset);
1931
- offset += 8;
1932
- const y = bytesToFloat64(bytes, offset);
1933
- offset += 8;
1934
- return {
1935
- srid,
1936
- point: [x, y]
1937
- };
1938
- }
1939
- throw new Error("Unsupported geometry type");
1940
- }
1941
-
1942
- // node_modules/drizzle-orm/codecs.js
1943
- var noopCodecs = {};
1944
- var arrayToItemTypeCodecNameMap = {
1945
- cast: "cast",
1946
- castArray: "cast",
1947
- castInJson: "castInJson",
1948
- castArrayInJson: "castInJson",
1949
- castParam: "castParam",
1950
- castArrayParam: "castParam",
1951
- normalize: "normalize",
1952
- normalizeArray: "normalize",
1953
- normalizeInJson: "normalizeInJson",
1954
- normalizeArrayInJson: "normalizeInJson",
1955
- normalizeParam: "normalizeParam",
1956
- normalizeParamArray: "normalizeParam"
1957
- };
1958
- var itemToArrayTypeCodecNameMap = {
1959
- cast: "castArray",
1960
- castArray: "castArray",
1961
- castInJson: "castArrayInJson",
1962
- castArrayInJson: "castArrayInJson",
1963
- castParam: "castArrayParam",
1964
- castArrayParam: "castArrayParam",
1965
- normalize: "normalizeArray",
1966
- normalizeArray: "normalizeArray",
1967
- normalizeInJson: "normalizeArrayInJson",
1968
- normalizeArrayInJson: "normalizeArrayInJson",
1969
- normalizeParam: "normalizeParamArray",
1970
- normalizeParamArray: "normalizeParamArray"
1971
- };
1972
- var CodecsCollection = class {
1973
- static [entityKind] = "CodecsCollection";
1974
- constructor(resolveTypes, codecs = noopCodecs) {
1975
- this.resolveTypes = resolveTypes;
1976
- this.codecs = codecs;
1977
- }
1978
- get(column, type) {
1979
- const sqlType = column.codec;
1980
- if (!sqlType)
1981
- return;
1982
- const codecType = column.dimensions ? itemToArrayTypeCodecNameMap[type] : arrayToItemTypeCodecNameMap[type];
1983
- return this.codecs[sqlType]?.[codecType];
1984
- }
1985
- apply(column, type, value) {
1986
- const sqlType = column.codec;
1987
- if (!sqlType)
1988
- return value;
1989
- const codecType = column.dimensions ? itemToArrayTypeCodecNameMap[type] : arrayToItemTypeCodecNameMap[type];
1990
- const codec = this.codecs[sqlType]?.[codecType];
1991
- if (!codec)
1992
- return value;
1993
- if (codecType === "castParam" || codecType === "castArrayParam")
1994
- return codec(value, column, column.dimensions);
1995
- return codec(value, column.dimensions);
1719
+ apply(column, type, value, override) {
1720
+ const sqlType = override ?? column.codec;
1721
+ if (!sqlType)
1722
+ return value;
1723
+ const codecType = column.dimensions ? itemToArrayTypeCodecNameMap[type] : arrayToItemTypeCodecNameMap[type];
1724
+ const codec = this.codecs[sqlType]?.[codecType];
1725
+ if (!codec)
1726
+ return value;
1727
+ if (codecType === "castParam" || codecType === "castArrayParam")
1728
+ return codec(value, column, column.dimensions);
1729
+ return codec(value, column.dimensions);
1996
1730
  }
1997
1731
  };
1998
1732
  function refineCodecs(source, extension = {}) {
@@ -2012,34 +1746,661 @@ function refineCodecs(source, extension = {}) {
2012
1746
  for (const ik of innerKeys)
2013
1747
  result[k][ik] = ik in extension[k] ? extension[k][ik] : source[k]?.[ik];
2014
1748
  }
2015
- return result;
2016
- }
2017
-
2018
- // node_modules/drizzle-orm/pg-core/codecs.js
2019
- var PG_ALIAS_TO_TYPE_MAP = {
2020
- int2: "smallint",
2021
- integer: "int",
2022
- int4: "int",
2023
- int8: "bigint",
2024
- decimal: "numeric",
2025
- real: "float4",
2026
- double: "float8",
2027
- "double precision": "float8",
2028
- serial2: "smallserial",
2029
- serial4: "serial",
2030
- serial8: "bigserial",
2031
- character: "char",
2032
- "character varying": "varchar",
2033
- "time with time zone": "timetz",
2034
- "time without time zone": "time",
2035
- "timestamp with time zone": "timestamptz",
2036
- "timestamp without time zone": "timestamp",
2037
- boolean: "bool",
2038
- "bit varying": "varbit"
1749
+ return result;
1750
+ }
1751
+
1752
+ // node_modules/drizzle-orm/pg-core/codecs.js
1753
+ var PG_ALIAS_TO_TYPE_MAP = {
1754
+ int2: "smallint",
1755
+ integer: "int",
1756
+ int4: "int",
1757
+ int8: "bigint",
1758
+ decimal: "numeric",
1759
+ real: "float4",
1760
+ double: "float8",
1761
+ "double precision": "float8",
1762
+ serial2: "smallserial",
1763
+ serial4: "serial",
1764
+ serial8: "bigserial",
1765
+ character: "char",
1766
+ "character varying": "varchar",
1767
+ "time with time zone": "timetz",
1768
+ "time without time zone": "time",
1769
+ "timestamp with time zone": "timestamptz",
1770
+ "timestamp without time zone": "timestamp",
1771
+ boolean: "bool",
1772
+ "bit varying": "varbit"
1773
+ };
1774
+ function resolvePgTypeAlias(type) {
1775
+ return PG_ALIAS_TO_TYPE_MAP[type] ?? type;
1776
+ }
1777
+ var unionsTypeTable = {
1778
+ smallint: {
1779
+ smallint: "smallint",
1780
+ int: "int",
1781
+ bigint: "bigint:number",
1782
+ "bigint:number": "bigint:number",
1783
+ "bigint:string": "bigint:number",
1784
+ numeric: "numeric:number",
1785
+ "numeric:number": "numeric:number",
1786
+ "numeric:bigint": "numeric:number",
1787
+ float4: "float4",
1788
+ float8: "float8",
1789
+ smallserial: "smallint",
1790
+ serial: "int",
1791
+ bigserial: "bigint:number",
1792
+ "bigserial:number": "bigint:number",
1793
+ oid: "oid",
1794
+ regproc: "regproc",
1795
+ regprocedure: "regprocedure",
1796
+ regoper: "regoper",
1797
+ regoperator: "regoperator",
1798
+ regclass: "regclass",
1799
+ regtype: "regtype",
1800
+ regrole: "regrole",
1801
+ regnamespace: "regnamespace",
1802
+ regconfig: "regconfig",
1803
+ regdictionary: "regdictionary"
1804
+ },
1805
+ int: {
1806
+ smallint: "int",
1807
+ int: "int",
1808
+ bigint: "bigint:number",
1809
+ "bigint:number": "bigint:number",
1810
+ "bigint:string": "bigint:number",
1811
+ numeric: "numeric:number",
1812
+ "numeric:number": "numeric:number",
1813
+ "numeric:bigint": "numeric:number",
1814
+ float4: "float4",
1815
+ float8: "float8",
1816
+ smallserial: "int",
1817
+ serial: "int",
1818
+ bigserial: "bigint:number",
1819
+ "bigserial:number": "bigint:number",
1820
+ oid: "oid",
1821
+ regproc: "regproc",
1822
+ regprocedure: "regprocedure",
1823
+ regoper: "regoper",
1824
+ regoperator: "regoperator",
1825
+ regclass: "regclass",
1826
+ regtype: "regtype",
1827
+ regrole: "regrole",
1828
+ regnamespace: "regnamespace",
1829
+ regconfig: "regconfig",
1830
+ regdictionary: "regdictionary"
1831
+ },
1832
+ bigint: {
1833
+ smallint: "bigint",
1834
+ int: "bigint",
1835
+ bigint: "bigint",
1836
+ "bigint:number": "bigint",
1837
+ "bigint:string": "bigint",
1838
+ numeric: "numeric:bigint",
1839
+ "numeric:number": "numeric:bigint",
1840
+ "numeric:bigint": "numeric:bigint",
1841
+ float4: "float4",
1842
+ float8: "float8",
1843
+ smallserial: "bigint",
1844
+ serial: "bigint",
1845
+ bigserial: "bigint",
1846
+ "bigserial:number": "bigint",
1847
+ oid: "oid",
1848
+ regproc: "regproc",
1849
+ regprocedure: "regprocedure",
1850
+ regoper: "regoper",
1851
+ regoperator: "regoperator",
1852
+ regclass: "regclass",
1853
+ regtype: "regtype",
1854
+ regrole: "regrole",
1855
+ regnamespace: "regnamespace",
1856
+ regconfig: "regconfig",
1857
+ regdictionary: "regdictionary"
1858
+ },
1859
+ "bigint:number": {
1860
+ smallint: "bigint:number",
1861
+ int: "bigint:number",
1862
+ bigint: "bigint:number",
1863
+ "bigint:number": "bigint:number",
1864
+ "bigint:string": "bigint:number",
1865
+ numeric: "numeric:number",
1866
+ "numeric:number": "numeric:number",
1867
+ "numeric:bigint": "numeric:number",
1868
+ float4: "float4",
1869
+ float8: "float8",
1870
+ smallserial: "bigint:number",
1871
+ serial: "bigint:number",
1872
+ bigserial: "bigint:number",
1873
+ "bigserial:number": "bigint:number",
1874
+ oid: "oid",
1875
+ regproc: "regproc",
1876
+ regprocedure: "regprocedure",
1877
+ regoper: "regoper",
1878
+ regoperator: "regoperator",
1879
+ regclass: "regclass",
1880
+ regtype: "regtype",
1881
+ regrole: "regrole",
1882
+ regnamespace: "regnamespace",
1883
+ regconfig: "regconfig",
1884
+ regdictionary: "regdictionary"
1885
+ },
1886
+ "bigint:string": {
1887
+ smallint: "bigint:string",
1888
+ int: "bigint:string",
1889
+ bigint: "bigint:string",
1890
+ "bigint:number": "bigint:string",
1891
+ "bigint:string": "bigint:string",
1892
+ numeric: "numeric",
1893
+ "numeric:number": "numeric",
1894
+ "numeric:bigint": "numeric",
1895
+ float4: "float4",
1896
+ float8: "float8",
1897
+ smallserial: "bigint:string",
1898
+ serial: "bigint:string",
1899
+ bigserial: "bigint:string",
1900
+ "bigserial:number": "bigint:string",
1901
+ oid: "oid",
1902
+ regproc: "regproc",
1903
+ regprocedure: "regprocedure",
1904
+ regoper: "regoper",
1905
+ regoperator: "regoperator",
1906
+ regclass: "regclass",
1907
+ regtype: "regtype",
1908
+ regrole: "regrole",
1909
+ regnamespace: "regnamespace",
1910
+ regconfig: "regconfig",
1911
+ regdictionary: "regdictionary"
1912
+ },
1913
+ numeric: {
1914
+ smallint: "numeric",
1915
+ int: "numeric",
1916
+ bigint: "numeric",
1917
+ "bigint:number": "numeric",
1918
+ "bigint:string": "numeric",
1919
+ numeric: "numeric",
1920
+ "numeric:number": "numeric",
1921
+ "numeric:bigint": "numeric",
1922
+ float4: "float4",
1923
+ float8: "float8",
1924
+ smallserial: "numeric",
1925
+ serial: "numeric",
1926
+ bigserial: "numeric",
1927
+ "bigserial:number": "numeric"
1928
+ },
1929
+ "numeric:number": {
1930
+ smallint: "numeric:number",
1931
+ int: "numeric:number",
1932
+ bigint: "numeric:number",
1933
+ "bigint:number": "numeric:number",
1934
+ "bigint:string": "numeric:number",
1935
+ numeric: "numeric:number",
1936
+ "numeric:number": "numeric:number",
1937
+ "numeric:bigint": "numeric:number",
1938
+ float4: "float4",
1939
+ float8: "float8",
1940
+ smallserial: "numeric:number",
1941
+ serial: "numeric:number",
1942
+ bigserial: "numeric:number",
1943
+ "bigserial:number": "numeric:number"
1944
+ },
1945
+ "numeric:bigint": {
1946
+ smallint: "numeric:bigint",
1947
+ int: "numeric:bigint",
1948
+ bigint: "numeric:bigint",
1949
+ "bigint:number": "numeric:bigint",
1950
+ "bigint:string": "numeric:bigint",
1951
+ numeric: "numeric:bigint",
1952
+ "numeric:number": "numeric:bigint",
1953
+ "numeric:bigint": "numeric:bigint",
1954
+ float4: "float4",
1955
+ float8: "float8",
1956
+ smallserial: "numeric:bigint",
1957
+ serial: "numeric:bigint",
1958
+ bigserial: "numeric:bigint",
1959
+ "bigserial:number": "numeric:bigint"
1960
+ },
1961
+ float4: {
1962
+ smallint: "float4",
1963
+ int: "float4",
1964
+ bigint: "float4",
1965
+ "bigint:number": "float4",
1966
+ "bigint:string": "float4",
1967
+ numeric: "float4",
1968
+ "numeric:number": "float4",
1969
+ "numeric:bigint": "float4",
1970
+ float4: "float4",
1971
+ float8: "float8",
1972
+ smallserial: "float4",
1973
+ serial: "float4",
1974
+ bigserial: "float4",
1975
+ "bigserial:number": "float4"
1976
+ },
1977
+ float8: {
1978
+ smallint: "float8",
1979
+ int: "float8",
1980
+ bigint: "float8",
1981
+ "bigint:number": "float8",
1982
+ "bigint:string": "float8",
1983
+ numeric: "float8",
1984
+ "numeric:number": "float8",
1985
+ "numeric:bigint": "float8",
1986
+ float4: "float8",
1987
+ float8: "float8",
1988
+ smallserial: "float8",
1989
+ serial: "float8",
1990
+ bigserial: "float8",
1991
+ "bigserial:number": "float8"
1992
+ },
1993
+ money: { money: "money" },
1994
+ smallserial: {
1995
+ smallint: "smallint",
1996
+ int: "int",
1997
+ bigint: "bigint:number",
1998
+ "bigint:number": "bigint:number",
1999
+ "bigint:string": "bigint:number",
2000
+ numeric: "numeric:number",
2001
+ "numeric:number": "numeric:number",
2002
+ "numeric:bigint": "numeric:number",
2003
+ float4: "float4",
2004
+ float8: "float8",
2005
+ smallserial: "smallint",
2006
+ serial: "int",
2007
+ bigserial: "bigint:number",
2008
+ "bigserial:number": "bigint:number",
2009
+ oid: "oid",
2010
+ regproc: "regproc",
2011
+ regprocedure: "regprocedure",
2012
+ regoper: "regoper",
2013
+ regoperator: "regoperator",
2014
+ regclass: "regclass",
2015
+ regtype: "regtype",
2016
+ regrole: "regrole",
2017
+ regnamespace: "regnamespace",
2018
+ regconfig: "regconfig",
2019
+ regdictionary: "regdictionary"
2020
+ },
2021
+ serial: {
2022
+ smallint: "int",
2023
+ int: "int",
2024
+ bigint: "bigint:number",
2025
+ "bigint:number": "bigint:number",
2026
+ "bigint:string": "bigint:number",
2027
+ numeric: "numeric:number",
2028
+ "numeric:number": "numeric:number",
2029
+ "numeric:bigint": "numeric:number",
2030
+ float4: "float4",
2031
+ float8: "float8",
2032
+ smallserial: "int",
2033
+ serial: "int",
2034
+ bigserial: "bigint:number",
2035
+ "bigserial:number": "bigint:number",
2036
+ oid: "oid",
2037
+ regproc: "regproc",
2038
+ regprocedure: "regprocedure",
2039
+ regoper: "regoper",
2040
+ regoperator: "regoperator",
2041
+ regclass: "regclass",
2042
+ regtype: "regtype",
2043
+ regrole: "regrole",
2044
+ regnamespace: "regnamespace",
2045
+ regconfig: "regconfig",
2046
+ regdictionary: "regdictionary"
2047
+ },
2048
+ bigserial: {
2049
+ smallint: "bigint",
2050
+ int: "bigint",
2051
+ bigint: "bigint",
2052
+ "bigint:number": "bigint",
2053
+ "bigint:string": "bigint",
2054
+ numeric: "numeric:bigint",
2055
+ "numeric:number": "numeric:bigint",
2056
+ "numeric:bigint": "numeric:bigint",
2057
+ float4: "float4",
2058
+ float8: "float8",
2059
+ smallserial: "bigint",
2060
+ serial: "bigint",
2061
+ bigserial: "bigint",
2062
+ "bigserial:number": "bigint",
2063
+ oid: "oid",
2064
+ regproc: "regproc",
2065
+ regprocedure: "regprocedure",
2066
+ regoper: "regoper",
2067
+ regoperator: "regoperator",
2068
+ regclass: "regclass",
2069
+ regtype: "regtype",
2070
+ regrole: "regrole",
2071
+ regnamespace: "regnamespace",
2072
+ regconfig: "regconfig",
2073
+ regdictionary: "regdictionary"
2074
+ },
2075
+ "bigserial:number": {
2076
+ smallint: "bigint:number",
2077
+ int: "bigint:number",
2078
+ bigint: "bigint:number",
2079
+ "bigint:number": "bigint:number",
2080
+ "bigint:string": "bigint:number",
2081
+ numeric: "numeric:number",
2082
+ "numeric:number": "numeric:number",
2083
+ "numeric:bigint": "numeric:number",
2084
+ float4: "float4",
2085
+ float8: "float8",
2086
+ smallserial: "bigint:number",
2087
+ serial: "bigint:number",
2088
+ bigserial: "bigint:number",
2089
+ "bigserial:number": "bigint:number",
2090
+ oid: "oid",
2091
+ regproc: "regproc",
2092
+ regprocedure: "regprocedure",
2093
+ regoper: "regoper",
2094
+ regoperator: "regoperator",
2095
+ regclass: "regclass",
2096
+ regtype: "regtype",
2097
+ regrole: "regrole",
2098
+ regnamespace: "regnamespace",
2099
+ regconfig: "regconfig",
2100
+ regdictionary: "regdictionary"
2101
+ },
2102
+ char: {
2103
+ char: "char",
2104
+ varchar: "char",
2105
+ text: "char"
2106
+ },
2107
+ varchar: {
2108
+ char: "varchar",
2109
+ varchar: "varchar",
2110
+ text: "varchar"
2111
+ },
2112
+ text: {
2113
+ char: "text",
2114
+ varchar: "text",
2115
+ text: "text"
2116
+ },
2117
+ bytea: { bytea: "bytea" },
2118
+ date: {
2119
+ date: "date",
2120
+ "date:string": "date",
2121
+ timestamp: "timestamp",
2122
+ "timestamp:string": "timestamp",
2123
+ timestamptz: "timestamptz",
2124
+ "timestamptz:string": "timestamptz"
2125
+ },
2126
+ "date:string": {
2127
+ date: "date:string",
2128
+ "date:string": "date:string",
2129
+ timestamp: "timestamp:string",
2130
+ "timestamp:string": "timestamp:string",
2131
+ timestamptz: "timestamptz:string",
2132
+ "timestamptz:string": "timestamptz:string"
2133
+ },
2134
+ time: {
2135
+ time: "time",
2136
+ timetz: "timetz"
2137
+ },
2138
+ timetz: {
2139
+ time: "timetz",
2140
+ timetz: "timetz"
2141
+ },
2142
+ timestamp: {
2143
+ date: "timestamp",
2144
+ "date:string": "timestamp",
2145
+ timestamp: "timestamp",
2146
+ "timestamp:string": "timestamp",
2147
+ timestamptz: "timestamptz",
2148
+ "timestamptz:string": "timestamptz"
2149
+ },
2150
+ "timestamp:string": {
2151
+ date: "timestamp:string",
2152
+ "date:string": "timestamp:string",
2153
+ timestamp: "timestamp:string",
2154
+ "timestamp:string": "timestamp:string",
2155
+ timestamptz: "timestamptz:string",
2156
+ "timestamptz:string": "timestamptz:string"
2157
+ },
2158
+ timestamptz: {
2159
+ date: "timestamptz",
2160
+ "date:string": "timestamptz",
2161
+ timestamp: "timestamptz",
2162
+ "timestamp:string": "timestamptz",
2163
+ timestamptz: "timestamptz",
2164
+ "timestamptz:string": "timestamptz"
2165
+ },
2166
+ "timestamptz:string": {
2167
+ date: "timestamptz:string",
2168
+ "date:string": "timestamptz:string",
2169
+ timestamp: "timestamptz:string",
2170
+ "timestamp:string": "timestamptz:string",
2171
+ timestamptz: "timestamptz:string",
2172
+ "timestamptz:string": "timestamptz:string"
2173
+ },
2174
+ interval: {
2175
+ interval: "interval",
2176
+ "interval:tuple": "interval"
2177
+ },
2178
+ "interval:tuple": {
2179
+ interval: "interval:tuple",
2180
+ "interval:tuple": "interval:tuple"
2181
+ },
2182
+ bool: { bool: "bool" },
2183
+ enum: { enum: "enum" },
2184
+ point: {
2185
+ point: "point",
2186
+ "point:tuple": "point"
2187
+ },
2188
+ "point:tuple": {
2189
+ point: "point:tuple",
2190
+ "point:tuple": "point:tuple"
2191
+ },
2192
+ line: {
2193
+ line: "line",
2194
+ "line:tuple": "line"
2195
+ },
2196
+ "line:tuple": {
2197
+ line: "line:tuple",
2198
+ "line:tuple": "line:tuple"
2199
+ },
2200
+ lseg: { lseg: "lseg" },
2201
+ box: { box: "box" },
2202
+ path: { path: "path" },
2203
+ polygon: { polygon: "polygon" },
2204
+ circle: { circle: "circle" },
2205
+ cidr: {
2206
+ cidr: "cidr",
2207
+ inet: "inet"
2208
+ },
2209
+ inet: {
2210
+ cidr: "inet",
2211
+ inet: "inet"
2212
+ },
2213
+ macaddr: {
2214
+ macaddr: "macaddr",
2215
+ macaddr8: "macaddr"
2216
+ },
2217
+ macaddr8: {
2218
+ macaddr: "macaddr8",
2219
+ macaddr8: "macaddr8"
2220
+ },
2221
+ bit: {
2222
+ bit: "bit",
2223
+ varbit: "bit"
2224
+ },
2225
+ varbit: {
2226
+ bit: "varbit",
2227
+ varbit: "varbit"
2228
+ },
2229
+ tsvector: { tsvector: "tsvector" },
2230
+ tsquery: { tsquery: "tsquery" },
2231
+ uuid: { uuid: "uuid" },
2232
+ xml: { xml: "xml" },
2233
+ json: { json: "json" },
2234
+ jsonb: { jsonb: "jsonb" },
2235
+ int4range: { int4range: "int4range" },
2236
+ int8range: { int8range: "int8range" },
2237
+ numrange: { numrange: "numrange" },
2238
+ tsrange: { tsrange: "tsrange" },
2239
+ tstzrange: { tstzrange: "tstzrange" },
2240
+ daterange: { daterange: "daterange" },
2241
+ int4multirange: { int4multirange: "int4multirange" },
2242
+ int8multirange: { int8multirange: "int8multirange" },
2243
+ nummultirange: { nummultirange: "nummultirange" },
2244
+ tsmultirange: { tsmultirange: "tsmultirange" },
2245
+ tstzmultirange: { tstzmultirange: "tstzmultirange" },
2246
+ datemultirange: { datemultirange: "datemultirange" },
2247
+ oid: {
2248
+ smallint: "oid",
2249
+ int: "oid",
2250
+ bigint: "oid",
2251
+ "bigint:number": "oid",
2252
+ "bigint:string": "oid",
2253
+ smallserial: "oid",
2254
+ serial: "oid",
2255
+ bigserial: "oid",
2256
+ "bigserial:number": "oid",
2257
+ oid: "oid",
2258
+ regproc: "oid",
2259
+ regprocedure: "oid",
2260
+ regoper: "oid",
2261
+ regoperator: "oid",
2262
+ regclass: "oid",
2263
+ regtype: "oid",
2264
+ regrole: "oid",
2265
+ regnamespace: "oid",
2266
+ regconfig: "oid",
2267
+ regdictionary: "oid"
2268
+ },
2269
+ regproc: {
2270
+ smallint: "regproc",
2271
+ int: "regproc",
2272
+ bigint: "regproc",
2273
+ "bigint:number": "regproc",
2274
+ "bigint:string": "regproc",
2275
+ smallserial: "regproc",
2276
+ serial: "regproc",
2277
+ bigserial: "regproc",
2278
+ "bigserial:number": "regproc",
2279
+ oid: "regproc",
2280
+ regproc: "regproc",
2281
+ regprocedure: "regproc"
2282
+ },
2283
+ regprocedure: {
2284
+ smallint: "regprocedure",
2285
+ int: "regprocedure",
2286
+ bigint: "regprocedure",
2287
+ "bigint:number": "regprocedure",
2288
+ "bigint:string": "regprocedure",
2289
+ smallserial: "regprocedure",
2290
+ serial: "regprocedure",
2291
+ bigserial: "regprocedure",
2292
+ "bigserial:number": "regprocedure",
2293
+ oid: "regprocedure",
2294
+ regproc: "regprocedure",
2295
+ regprocedure: "regprocedure"
2296
+ },
2297
+ regoper: {
2298
+ smallint: "regoper",
2299
+ int: "regoper",
2300
+ bigint: "regoper",
2301
+ "bigint:number": "regoper",
2302
+ "bigint:string": "regoper",
2303
+ smallserial: "regoper",
2304
+ serial: "regoper",
2305
+ bigserial: "regoper",
2306
+ "bigserial:number": "regoper",
2307
+ oid: "regoper",
2308
+ regoper: "regoper",
2309
+ regoperator: "regoper"
2310
+ },
2311
+ regoperator: {
2312
+ smallint: "regoperator",
2313
+ int: "regoperator",
2314
+ bigint: "regoperator",
2315
+ "bigint:number": "regoperator",
2316
+ "bigint:string": "regoperator",
2317
+ smallserial: "regoperator",
2318
+ serial: "regoperator",
2319
+ bigserial: "regoperator",
2320
+ "bigserial:number": "regoperator",
2321
+ oid: "regoperator",
2322
+ regoper: "regoperator",
2323
+ regoperator: "regoperator"
2324
+ },
2325
+ regclass: {
2326
+ smallint: "regclass",
2327
+ int: "regclass",
2328
+ bigint: "regclass",
2329
+ "bigint:number": "regclass",
2330
+ "bigint:string": "regclass",
2331
+ smallserial: "regclass",
2332
+ serial: "regclass",
2333
+ bigserial: "regclass",
2334
+ "bigserial:number": "regclass",
2335
+ oid: "regclass",
2336
+ regclass: "regclass"
2337
+ },
2338
+ regtype: {
2339
+ smallint: "regtype",
2340
+ int: "regtype",
2341
+ bigint: "regtype",
2342
+ "bigint:number": "regtype",
2343
+ "bigint:string": "regtype",
2344
+ smallserial: "regtype",
2345
+ serial: "regtype",
2346
+ bigserial: "regtype",
2347
+ "bigserial:number": "regtype",
2348
+ oid: "regtype",
2349
+ regtype: "regtype"
2350
+ },
2351
+ regrole: {
2352
+ smallint: "regrole",
2353
+ int: "regrole",
2354
+ bigint: "regrole",
2355
+ "bigint:number": "regrole",
2356
+ "bigint:string": "regrole",
2357
+ smallserial: "regrole",
2358
+ serial: "regrole",
2359
+ bigserial: "regrole",
2360
+ "bigserial:number": "regrole",
2361
+ oid: "regrole",
2362
+ regrole: "regrole"
2363
+ },
2364
+ regnamespace: {
2365
+ smallint: "regnamespace",
2366
+ int: "regnamespace",
2367
+ bigint: "regnamespace",
2368
+ "bigint:number": "regnamespace",
2369
+ "bigint:string": "regnamespace",
2370
+ smallserial: "regnamespace",
2371
+ serial: "regnamespace",
2372
+ bigserial: "regnamespace",
2373
+ "bigserial:number": "regnamespace",
2374
+ oid: "regnamespace",
2375
+ regnamespace: "regnamespace"
2376
+ },
2377
+ regconfig: {
2378
+ smallint: "regconfig",
2379
+ int: "regconfig",
2380
+ bigint: "regconfig",
2381
+ "bigint:number": "regconfig",
2382
+ "bigint:string": "regconfig",
2383
+ smallserial: "regconfig",
2384
+ serial: "regconfig",
2385
+ bigserial: "regconfig",
2386
+ "bigserial:number": "regconfig",
2387
+ oid: "regconfig",
2388
+ regconfig: "regconfig"
2389
+ },
2390
+ regdictionary: {
2391
+ smallint: "regdictionary",
2392
+ int: "regdictionary",
2393
+ bigint: "regdictionary",
2394
+ "bigint:number": "regdictionary",
2395
+ "bigint:string": "regdictionary",
2396
+ smallserial: "regdictionary",
2397
+ serial: "regdictionary",
2398
+ bigserial: "regdictionary",
2399
+ "bigserial:number": "regdictionary",
2400
+ oid: "regdictionary",
2401
+ regdictionary: "regdictionary"
2402
+ }
2039
2403
  };
2040
- function resolvePgTypeAlias(type) {
2041
- return PG_ALIAS_TO_TYPE_MAP[type] ?? type;
2042
- }
2043
2404
  var castToText = (name2) => sql`${name2}::text`;
2044
2405
  var castToTextArr = (name2, arrayDimensions) => sql`${name2}::text${sql.raw("[]".repeat(arrayDimensions))}`;
2045
2406
  var arrayCompatCast = (cast) => (name2, arrayDimensions) => {
@@ -2293,57 +2654,368 @@ var genericPgCodecs = {
2293
2654
  normalizeArrayInJson: arrayCompatNormalize(parsePgVector)
2294
2655
  }
2295
2656
  };
2296
- var refineGenericPgCodecs = (extension) => refineCodecs(genericPgCodecs, extension);
2657
+ var refineGenericPgCodecs = (extension) => refineCodecs(genericPgCodecs, extension);
2658
+
2659
+ // node_modules/drizzle-orm/pg-core/columns/custom.js
2660
+ var PgCustomColumnBuilder = class extends PgColumnBuilder {
2661
+ static [entityKind] = "PgCustomColumnBuilder";
2662
+ constructor(name2, fieldConfig, customTypeParams) {
2663
+ super(name2, "custom", "PgCustomColumn");
2664
+ this.config.fieldConfig = fieldConfig;
2665
+ this.config.customTypeParams = customTypeParams;
2666
+ }
2667
+ build(table) {
2668
+ return new PgCustomColumn(table, this.config);
2669
+ }
2670
+ };
2671
+ var PgCustomColumn = class extends PgColumn {
2672
+ static [entityKind] = "PgCustomColumn";
2673
+ codec;
2674
+ sqlName;
2675
+ mapFromJsonValue;
2676
+ jsonSelectIdentifier;
2677
+ constructor(table, config) {
2678
+ super(table, config);
2679
+ this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
2680
+ this.mapToDriverValue = config.customTypeParams.toDriver ?? this.mapToDriverValue;
2681
+ this.mapFromDriverValue = config.customTypeParams.fromDriver ?? this.mapFromDriverValue;
2682
+ this.mapFromJsonValue = config.customTypeParams.fromJson;
2683
+ this.jsonSelectIdentifier = config.customTypeParams.forJsonSelect;
2684
+ const cfgCodec = typeof config.customTypeParams.codec === "string" || typeof config.customTypeParams.codec === "undefined" ? config.customTypeParams.codec : config.customTypeParams.codec(config.fieldConfig);
2685
+ this.codec = typeof cfgCodec === "string" ? resolvePgTypeAlias(cfgCodec) : undefined;
2686
+ if (this.dimensions && config.customTypeParams.fromJson)
2687
+ this.mapFromJsonValue = (value) => {
2688
+ if (value === null)
2689
+ return value;
2690
+ const arr = typeof value === "string" ? parsePgArray(value) : value;
2691
+ return this.mapJsonArrayElements(arr, config.customTypeParams.fromJson, this.dimensions);
2692
+ };
2693
+ }
2694
+ mapJsonArrayElements(value, mapper, depth) {
2695
+ if (depth > 0 && Array.isArray(value))
2696
+ return value.map((v) => v === null ? null : this.mapJsonArrayElements(v, mapper, depth - 1));
2697
+ return mapper(value);
2698
+ }
2699
+ getSQLType() {
2700
+ return this.sqlName;
2701
+ }
2702
+ };
2703
+ function customType(customTypeParams) {
2704
+ return (a, b) => {
2705
+ const { name: name2, config } = getColumnNameAndConfig2(a, b);
2706
+ return new PgCustomColumnBuilder(name2, config, customTypeParams);
2707
+ };
2708
+ }
2709
+ // node_modules/drizzle-orm/pg-core/columns/double-precision.js
2710
+ var PgDoublePrecisionBuilder = class extends PgColumnBuilder {
2711
+ static [entityKind] = "PgDoublePrecisionBuilder";
2712
+ constructor(name2) {
2713
+ super(name2, "number double", "PgDoublePrecision");
2714
+ }
2715
+ build(table) {
2716
+ return new PgDoublePrecision(table, this.config);
2717
+ }
2718
+ };
2719
+ var PgDoublePrecision = class extends PgColumn {
2720
+ static [entityKind] = "PgDoublePrecision";
2721
+ codec = "float8";
2722
+ getSQLType() {
2723
+ return "double precision";
2724
+ }
2725
+ };
2726
+ function doublePrecision(name2) {
2727
+ return new PgDoublePrecisionBuilder(name2 ?? "");
2728
+ }
2729
+ // node_modules/drizzle-orm/pg-core/columns/integer.js
2730
+ var PgIntegerBuilder = class extends PgIntColumnBuilder {
2731
+ static [entityKind] = "PgIntegerBuilder";
2732
+ constructor(name2) {
2733
+ super(name2, "number int32", "PgInteger");
2734
+ }
2735
+ build(table) {
2736
+ return new PgInteger(table, this.config);
2737
+ }
2738
+ };
2739
+ var PgInteger = class extends PgColumn {
2740
+ static [entityKind] = "PgInteger";
2741
+ codec = "int";
2742
+ getSQLType() {
2743
+ return "integer";
2744
+ }
2745
+ };
2746
+ function integer(name2) {
2747
+ return new PgIntegerBuilder(name2 ?? "");
2748
+ }
2749
+ // node_modules/drizzle-orm/pg-core/columns/jsonb.js
2750
+ var PgJsonbBuilder = class extends PgColumnBuilder {
2751
+ static [entityKind] = "PgJsonbBuilder";
2752
+ constructor(name2) {
2753
+ super(name2, "object json", "PgJsonb");
2754
+ }
2755
+ build(table) {
2756
+ return new PgJsonb(table, this.config);
2757
+ }
2758
+ };
2759
+ var PgJsonb = class extends PgColumn {
2760
+ static [entityKind] = "PgJsonb";
2761
+ codec = "jsonb";
2762
+ constructor(table, config) {
2763
+ super(table, config);
2764
+ }
2765
+ getSQLType() {
2766
+ return "jsonb";
2767
+ }
2768
+ };
2769
+ function jsonb(name2) {
2770
+ return new PgJsonbBuilder(name2 ?? "");
2771
+ }
2772
+ // node_modules/drizzle-orm/pg-core/columns/smallint.js
2773
+ var PgSmallIntBuilder = class extends PgIntColumnBuilder {
2774
+ static [entityKind] = "PgSmallIntBuilder";
2775
+ constructor(name2) {
2776
+ super(name2, "number int16", "PgSmallInt");
2777
+ }
2778
+ build(table) {
2779
+ return new PgSmallInt(table, this.config);
2780
+ }
2781
+ };
2782
+ var PgSmallInt = class extends PgColumn {
2783
+ static [entityKind] = "PgSmallInt";
2784
+ codec = "smallint";
2785
+ getSQLType() {
2786
+ return "smallint";
2787
+ }
2788
+ };
2789
+ function smallint(name2) {
2790
+ return new PgSmallIntBuilder(name2 ?? "");
2791
+ }
2792
+ // node_modules/drizzle-orm/pg-core/columns/text.js
2793
+ var PgTextBuilder = class extends PgColumnBuilder {
2794
+ static [entityKind] = "PgTextBuilder";
2795
+ constructor(name2, config) {
2796
+ super(name2, config.enum?.length ? "string enum" : "string", "PgText");
2797
+ this.config.enumValues = config.enum;
2798
+ }
2799
+ build(table) {
2800
+ return new PgText(table, this.config, this.config.enumValues);
2801
+ }
2802
+ };
2803
+ var PgText = class extends PgColumn {
2804
+ static [entityKind] = "PgText";
2805
+ enumValues;
2806
+ codec = "text";
2807
+ constructor(table, config, enumValues) {
2808
+ super(table, config);
2809
+ this.enumValues = enumValues;
2810
+ }
2811
+ getSQLType() {
2812
+ return "text";
2813
+ }
2814
+ };
2815
+ function text(a, b = {}) {
2816
+ const { name: name2, config } = getColumnNameAndConfig2(a, b);
2817
+ return new PgTextBuilder(name2, config);
2818
+ }
2819
+ // node_modules/drizzle-orm/pg-core/columns/date.common.js
2820
+ var PgDateColumnBuilder = class extends PgColumnBuilder {
2821
+ static [entityKind] = "PgDateColumnBaseBuilder";
2822
+ defaultNow() {
2823
+ return this.default(sql`now()`);
2824
+ }
2825
+ };
2826
+
2827
+ // node_modules/drizzle-orm/pg-core/columns/timestamp.js
2828
+ var PgTimestampBuilder = class extends PgDateColumnBuilder {
2829
+ static [entityKind] = "PgTimestampBuilder";
2830
+ constructor(name2, withTimezone, precision) {
2831
+ super(name2, "object date", "PgTimestamp");
2832
+ this.config.withTimezone = withTimezone;
2833
+ this.config.precision = precision;
2834
+ }
2835
+ build(table) {
2836
+ return new PgTimestamp(table, this.config);
2837
+ }
2838
+ };
2839
+ var PgTimestamp = class extends PgColumn {
2840
+ static [entityKind] = "PgTimestamp";
2841
+ codec;
2842
+ withTimezone;
2843
+ precision;
2844
+ constructor(table, config) {
2845
+ super(table, config);
2846
+ this.withTimezone = config.withTimezone;
2847
+ this.precision = config.precision;
2848
+ this.codec = this.withTimezone ? "timestamptz" : "timestamp";
2849
+ }
2850
+ getSQLType() {
2851
+ return `timestamp${this.precision === undefined ? "" : ` (${this.precision})`}${this.withTimezone ? " with time zone" : ""}`;
2852
+ }
2853
+ mapToDriverValue = (value) => {
2854
+ if (typeof value === "string")
2855
+ return value;
2856
+ return value.toISOString();
2857
+ };
2858
+ };
2859
+ var PgTimestampStringBuilder = class extends PgDateColumnBuilder {
2860
+ static [entityKind] = "PgTimestampStringBuilder";
2861
+ constructor(name2, withTimezone, precision) {
2862
+ super(name2, "string timestamp", "PgTimestampString");
2863
+ this.config.withTimezone = withTimezone;
2864
+ this.config.precision = precision;
2865
+ }
2866
+ build(table) {
2867
+ return new PgTimestampString(table, this.config);
2868
+ }
2869
+ };
2870
+ var PgTimestampString = class extends PgColumn {
2871
+ static [entityKind] = "PgTimestampString";
2872
+ codec;
2873
+ withTimezone;
2874
+ precision;
2875
+ constructor(table, config) {
2876
+ super(table, config);
2877
+ this.withTimezone = config.withTimezone;
2878
+ this.precision = config.precision;
2879
+ this.codec = this.withTimezone ? "timestamptz:string" : "timestamp:string";
2880
+ }
2881
+ getSQLType() {
2882
+ return `timestamp${this.precision === undefined ? "" : `(${this.precision})`}${this.withTimezone ? " with time zone" : ""}`;
2883
+ }
2884
+ mapToDriverValue = (value) => {
2885
+ if (typeof value === "string")
2886
+ return value;
2887
+ return value.toISOString();
2888
+ };
2889
+ };
2890
+ function timestamp(a, b = {}) {
2891
+ const { name: name2, config } = getColumnNameAndConfig2(a, b);
2892
+ if (config?.mode === "string")
2893
+ return new PgTimestampStringBuilder(name2, config.withTimezone ?? false, config.precision);
2894
+ return new PgTimestampBuilder(name2, config?.withTimezone ?? false, config?.precision);
2895
+ }
2896
+ // node_modules/drizzle-orm/pg-core/columns/varchar.js
2897
+ var PgVarcharBuilder = class extends PgColumnBuilder {
2898
+ static [entityKind] = "PgVarcharBuilder";
2899
+ constructor(name2, config) {
2900
+ super(name2, config.enum?.length ? "string enum" : "string", "PgVarchar");
2901
+ this.config.length = config.length;
2902
+ this.config.enumValues = config.enum;
2903
+ }
2904
+ build(table) {
2905
+ return new PgVarchar(table, this.config);
2906
+ }
2907
+ };
2908
+ var PgVarchar = class extends PgColumn {
2909
+ static [entityKind] = "PgVarchar";
2910
+ codec = "varchar";
2911
+ enumValues;
2912
+ constructor(table, config) {
2913
+ super(table, config);
2914
+ this.enumValues = config.enumValues;
2915
+ }
2916
+ getSQLType() {
2917
+ return this.length === undefined ? `varchar` : `varchar(${this.length})`;
2918
+ }
2919
+ };
2920
+ function varchar(a, b = {}) {
2921
+ const { name: name2, config } = getColumnNameAndConfig2(a, b);
2922
+ return new PgVarcharBuilder(name2, config);
2923
+ }
2924
+ // node_modules/drizzle-orm/pg-core/columns/bigserial.js
2925
+ var PgBigSerial53Builder = class extends PgColumnBuilder {
2926
+ static [entityKind] = "PgBigSerial53Builder";
2927
+ constructor(name2) {
2928
+ super(name2, "number int53", "PgBigSerial53");
2929
+ this.config.hasDefault = true;
2930
+ this.config.notNull = true;
2931
+ }
2932
+ build(table) {
2933
+ return new PgBigSerial53(table, this.config);
2934
+ }
2935
+ };
2936
+ var PgBigSerial53 = class extends PgColumn {
2937
+ static [entityKind] = "PgBigSerial53";
2938
+ codec = "bigserial:number";
2939
+ getSQLType() {
2940
+ return "bigserial";
2941
+ }
2942
+ };
2943
+ var PgBigSerial64Builder = class extends PgColumnBuilder {
2944
+ static [entityKind] = "PgBigSerial64Builder";
2945
+ constructor(name2) {
2946
+ super(name2, "bigint int64", "PgBigSerial64");
2947
+ this.config.hasDefault = true;
2948
+ this.config.notNull = true;
2949
+ }
2950
+ build(table) {
2951
+ return new PgBigSerial64(table, this.config);
2952
+ }
2953
+ };
2954
+ var PgBigSerial64 = class extends PgColumn {
2955
+ static [entityKind] = "PgBigSerial64";
2956
+ codec = "bigserial";
2957
+ getSQLType() {
2958
+ return "bigserial";
2959
+ }
2960
+ };
2961
+ function bigserial(a, b) {
2962
+ const { name: name2, config } = getColumnNameAndConfig2(a, b);
2963
+ if (config.mode === "number")
2964
+ return new PgBigSerial53Builder(name2);
2965
+ return new PgBigSerial64Builder(name2);
2966
+ }
2297
2967
 
2298
- // node_modules/drizzle-orm/pg-core/columns/custom.js
2299
- var PgCustomColumnBuilder = class extends PgColumnBuilder {
2300
- static [entityKind] = "PgCustomColumnBuilder";
2301
- constructor(name2, fieldConfig, customTypeParams) {
2302
- super(name2, "custom", "PgCustomColumn");
2303
- this.config.fieldConfig = fieldConfig;
2304
- this.config.customTypeParams = customTypeParams;
2968
+ // node_modules/drizzle-orm/pg-core/columns/char.js
2969
+ var PgCharBuilder = class extends PgColumnBuilder {
2970
+ static [entityKind] = "PgCharBuilder";
2971
+ constructor(name2, config) {
2972
+ super(name2, config.enum?.length ? "string enum" : "string", "PgChar");
2973
+ this.config.length = config.length ?? 1;
2974
+ this.config.setLength = config.length !== undefined;
2975
+ this.config.enumValues = config.enum;
2305
2976
  }
2306
2977
  build(table) {
2307
- return new PgCustomColumn(table, this.config);
2978
+ return new PgChar(table, this.config);
2308
2979
  }
2309
2980
  };
2310
- var PgCustomColumn = class extends PgColumn {
2311
- static [entityKind] = "PgCustomColumn";
2312
- codec;
2313
- sqlName;
2314
- mapFromJsonValue;
2315
- jsonSelectIdentifier;
2981
+ var PgChar = class extends PgColumn {
2982
+ static [entityKind] = "PgChar";
2983
+ codec = "char";
2984
+ enumValues;
2985
+ setLength;
2316
2986
  constructor(table, config) {
2317
2987
  super(table, config);
2318
- this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
2319
- this.mapToDriverValue = config.customTypeParams.toDriver ?? this.mapToDriverValue;
2320
- this.mapFromDriverValue = config.customTypeParams.fromDriver ?? this.mapFromDriverValue;
2321
- this.mapFromJsonValue = config.customTypeParams.fromJson;
2322
- this.jsonSelectIdentifier = config.customTypeParams.forJsonSelect;
2323
- const cfgCodec = typeof config.customTypeParams.codec === "string" || typeof config.customTypeParams.codec === "undefined" ? config.customTypeParams.codec : config.customTypeParams.codec(config.fieldConfig);
2324
- this.codec = typeof cfgCodec === "string" ? resolvePgTypeAlias(cfgCodec) : undefined;
2325
- if (this.dimensions && config.customTypeParams.fromJson)
2326
- this.mapFromJsonValue = (value) => {
2327
- if (value === null)
2328
- return value;
2329
- const arr = typeof value === "string" ? parsePgArray(value) : value;
2330
- return this.mapJsonArrayElements(arr, config.customTypeParams.fromJson, this.dimensions);
2331
- };
2988
+ this.enumValues = config.enumValues;
2989
+ this.setLength = config.setLength;
2332
2990
  }
2333
- mapJsonArrayElements(value, mapper, depth) {
2334
- if (depth > 0 && Array.isArray(value))
2335
- return value.map((v) => v === null ? null : this.mapJsonArrayElements(v, mapper, depth - 1));
2336
- return mapper(value);
2991
+ getSQLType() {
2992
+ return this.setLength ? `char(${this.length})` : `char`;
2993
+ }
2994
+ };
2995
+ function char(a, b = {}) {
2996
+ const { name: name2, config } = getColumnNameAndConfig2(a, b);
2997
+ return new PgCharBuilder(name2, config);
2998
+ }
2999
+
3000
+ // node_modules/drizzle-orm/pg-core/columns/cidr.js
3001
+ var PgCidrBuilder = class extends PgColumnBuilder {
3002
+ static [entityKind] = "PgCidrBuilder";
3003
+ constructor(name2) {
3004
+ super(name2, "string cidr", "PgCidr");
2337
3005
  }
3006
+ build(table) {
3007
+ return new PgCidr(table, this.config);
3008
+ }
3009
+ };
3010
+ var PgCidr = class extends PgColumn {
3011
+ static [entityKind] = "PgCidr";
3012
+ codec = "cidr";
2338
3013
  getSQLType() {
2339
- return this.sqlName;
3014
+ return "cidr";
2340
3015
  }
2341
3016
  };
2342
- function customType(customTypeParams) {
2343
- return (a, b) => {
2344
- const { name: name2, config } = getColumnNameAndConfig2(a, b);
2345
- return new PgCustomColumnBuilder(name2, config, customTypeParams);
2346
- };
3017
+ function cidr(name2) {
3018
+ return new PgCidrBuilder(name2 ?? "");
2347
3019
  }
2348
3020
 
2349
3021
  // node_modules/drizzle-orm/pg-core/columns/date.js
@@ -8357,12 +9029,12 @@ async function hashQuery(sql2, params) {
8357
9029
  var PgCountBuilder = class PgCountBuilder2 extends SQL {
8358
9030
  static [entityKind] = "PgCountBuilder";
8359
9031
  dialect;
8360
- static buildEmbeddedCount(source, filters, parens) {
9032
+ static buildCount(source, filters, parens) {
8361
9033
  const query = sql`select count(*) from ${source}${sql` where ${filters}`.if(filters)}`;
8362
9034
  return parens ? sql`(${query})` : query;
8363
9035
  }
8364
9036
  constructor(countConfig) {
8365
- super(PgCountBuilder2.buildEmbeddedCount(countConfig.source, countConfig.filters, true).queryChunks);
9037
+ super(PgCountBuilder2.buildCount(countConfig.source, countConfig.filters, true).queryChunks);
8366
9038
  this.countConfig = countConfig;
8367
9039
  this.dialect = countConfig.dialect;
8368
9040
  this.mapWith((e) => {
@@ -8371,10 +9043,13 @@ var PgCountBuilder = class PgCountBuilder2 extends SQL {
8371
9043
  return Number(e ?? 0);
8372
9044
  });
8373
9045
  }
9046
+ executableSql;
8374
9047
  build() {
8375
- const { filters, source } = this.countConfig;
8376
- const query = PgCountBuilder2.buildEmbeddedCount(source, filters);
8377
- return this.dialect.sqlToQuery(query);
9048
+ if (!this.executableSql) {
9049
+ const { source, filters } = this.countConfig;
9050
+ this.executableSql = PgCountBuilder2.buildCount(source, filters);
9051
+ }
9052
+ return this.dialect.sqlToQuery(this.executableSql);
8378
9053
  }
8379
9054
  };
8380
9055
 
@@ -8626,7 +9301,6 @@ var SelectionProxyHandler = class SelectionProxyHandler2 {
8626
9301
  var PgDeleteBase2 = class {
8627
9302
  static [entityKind] = "PgDelete";
8628
9303
  config;
8629
- cacheConfig;
8630
9304
  constructor(table, session, dialect, withList) {
8631
9305
  this.session = session;
8632
9306
  this.dialect = dialect;
@@ -8674,7 +9348,7 @@ var PgDeleteBase2 = class {
8674
9348
  var PgAsyncDeleteBase2 = class extends PgDeleteBase2 {
8675
9349
  static [entityKind] = "PgAsyncDelete";
8676
9350
  _prepare(name2, generateName = false) {
8677
- const { session, config, dialect, cacheConfig } = this;
9351
+ const { session, config, dialect } = this;
8678
9352
  const { returning: fields } = config;
8679
9353
  return tracer.startActiveSpan("drizzle.prepareQuery", () => {
8680
9354
  const query = dialect.sqlToQuery(this.getSQL());
@@ -8682,7 +9356,7 @@ var PgAsyncDeleteBase2 = class extends PgDeleteBase2 {
8682
9356
  return session.prepareQuery(query, fields ? "arrays" : "raw", name2 ?? generateName, mapper, {
8683
9357
  type: "delete",
8684
9358
  tables: [...extractUsedTable(this.config.table)]
8685
- }, cacheConfig);
9359
+ });
8686
9360
  });
8687
9361
  }
8688
9362
  prepare(name2) {
@@ -8729,7 +9403,6 @@ var PgSelectBuilder2 = class {
8729
9403
  if (config.withList)
8730
9404
  this.withList = config.withList;
8731
9405
  this.distinct = config.distinct;
8732
- this.tagged = config.tagged;
8733
9406
  }
8734
9407
  from(source) {
8735
9408
  const isPartialSelect = !!this.fields;
@@ -8752,8 +9425,7 @@ var PgSelectBuilder2 = class {
8752
9425
  session: this.session,
8753
9426
  dialect: this.dialect,
8754
9427
  withList: this.withList,
8755
- distinct: this.distinct,
8756
- tagged: this.tagged
9428
+ distinct: this.distinct
8757
9429
  });
8758
9430
  }
8759
9431
  };
@@ -8777,8 +9449,7 @@ var PgSelectBase2 = class extends TypedQueryBuilder {
8777
9449
  table: config.table,
8778
9450
  fields: { ...config.fields },
8779
9451
  distinct: config.distinct,
8780
- setOperators: [],
8781
- _tagged: config.tagged
9452
+ setOperators: []
8782
9453
  };
8783
9454
  this.isPartialSelect = config.isPartialSelect;
8784
9455
  this._ = {
@@ -8955,6 +9626,7 @@ var PgSelectBase2 = class extends TypedQueryBuilder {
8955
9626
  return this;
8956
9627
  }
8957
9628
  getSQL() {
9629
+ this.config.fieldsFlat = orderSelectedFields2(this.config.fields, undefined, this.dialect.codecs);
8958
9630
  return this.dialect.buildSelectQuery(this.config);
8959
9631
  }
8960
9632
  toSQL() {
@@ -9050,7 +9722,6 @@ params: ${params}`);
9050
9722
  this.cause = cause;
9051
9723
  }
9052
9724
  };
9053
-
9054
9725
  // node_modules/drizzle-orm/relations.js
9055
9726
  var Relation2 = class {
9056
9727
  static [entityKind] = "RelationV2";
@@ -9131,15 +9802,13 @@ var orderByOperators2 = {
9131
9802
  asc,
9132
9803
  desc
9133
9804
  };
9134
- function mapRelationalRow2(rows, isOne, buildQueryResultSelection, mapColumnValue, parseJson = false, parseJsonIfString = false, useJsonMappers = true) {
9805
+ function mapRelationalRow2(rows, isOne, buildQueryResultSelection, parseJson = false, parseJsonIfString = false, useJsonMappers = true) {
9135
9806
  const maxIdx = isOne ? 1 : rows.length;
9136
9807
  const decoders = buildQueryResultSelection.map(({ field, codec, arrayDimensions }) => {
9137
9808
  let decoder;
9138
- if (is(field, Column)) {
9139
- if (useJsonMappers && field.mapFromJsonValue)
9140
- return (v2) => field.mapFromJsonValue(v2);
9809
+ if (is(field, Column))
9141
9810
  decoder = field;
9142
- } else if (is(field, SQL))
9811
+ else if (is(field, SQL))
9143
9812
  decoder = field.decoder;
9144
9813
  else if (is(field, SQL.Aliased))
9145
9814
  decoder = field.sql.decoder;
@@ -9147,6 +9816,8 @@ function mapRelationalRow2(rows, isOne, buildQueryResultSelection, mapColumnValu
9147
9816
  decoder = noopDecoder;
9148
9817
  else
9149
9818
  decoder = field.getSQL().decoder;
9819
+ if (useJsonMappers && field.mapFromJsonValue)
9820
+ return (v2) => field.mapFromJsonValue(v2);
9150
9821
  return decoder.mapFromDriverValue.isNoop ? codec ? (value) => codec(value, arrayDimensions) : undefined : codec ? (value) => decoder.mapFromDriverValue(codec(value, arrayDimensions)) : (value) => decoder.mapFromDriverValue(value);
9151
9822
  });
9152
9823
  for (let i = 0;i < maxIdx; ++i) {
@@ -9163,14 +9834,12 @@ function mapRelationalRow2(rows, isOne, buildQueryResultSelection, mapColumnValu
9163
9834
  } else if (parseJsonIfString && typeof row[selectionItem.key] === "string")
9164
9835
  row[selectionItem.key] = JSON.parse(row[selectionItem.key]);
9165
9836
  if (selectionItem.isArray) {
9166
- mapRelationalRow2(row[selectionItem.key], false, selectionItem.selection, mapColumnValue, false, parseJsonIfString);
9837
+ mapRelationalRow2(row[selectionItem.key], false, selectionItem.selection, false, parseJsonIfString);
9167
9838
  continue;
9168
9839
  }
9169
- mapRelationalRow2(row[selectionItem.key], true, selectionItem.selection, mapColumnValue, false, parseJsonIfString);
9840
+ mapRelationalRow2(row[selectionItem.key], true, selectionItem.selection, false, parseJsonIfString);
9170
9841
  continue;
9171
9842
  }
9172
- if (mapColumnValue)
9173
- row[selectionItem.key] = mapColumnValue(row[selectionItem.key]);
9174
9843
  if (row[selectionItem.key] === null)
9175
9844
  continue;
9176
9845
  const decoder = decoders[selectionItemIdx];
@@ -9181,7 +9850,7 @@ function mapRelationalRow2(rows, isOne, buildQueryResultSelection, mapColumnValu
9181
9850
  }
9182
9851
  return rows;
9183
9852
  }
9184
- function mapRelationalRowFromArrays2(rows, isOne, buildQueryResultSelection, mapColumnValue, parseJson = false, parseJsonIfString = false) {
9853
+ function mapRelationalRowFromArrays2(rows, isOne, buildQueryResultSelection, parseJson = false, parseJsonIfString = false) {
9185
9854
  const maxIdx = isOne ? 1 : rows.length;
9186
9855
  const decoders = buildQueryResultSelection.map(({ field, codec, arrayDimensions }) => {
9187
9856
  let decoder;
@@ -9218,14 +9887,12 @@ function mapRelationalRowFromArrays2(rows, isOne, buildQueryResultSelection, map
9218
9887
  } else if (parseJsonIfString && typeof value === "string")
9219
9888
  value = JSON.parse(value);
9220
9889
  if (selectionItem.isArray)
9221
- mapRelationalRow2(value, false, selectionItem.selection, mapColumnValue, false, parseJsonIfString);
9890
+ mapRelationalRow2(value, false, selectionItem.selection, false, parseJsonIfString);
9222
9891
  else
9223
- mapRelationalRow2(value, true, selectionItem.selection, mapColumnValue, false, parseJsonIfString);
9892
+ mapRelationalRow2(value, true, selectionItem.selection, false, parseJsonIfString);
9224
9893
  result[selectionItem.key] = value;
9225
9894
  continue;
9226
9895
  }
9227
- if (mapColumnValue)
9228
- value = mapColumnValue(value);
9229
9896
  if (value === null) {
9230
9897
  result[selectionItem.key] = null;
9231
9898
  continue;
@@ -9237,14 +9904,14 @@ function mapRelationalRowFromArrays2(rows, isOne, buildQueryResultSelection, map
9237
9904
  }
9238
9905
  return isOne ? results[0] : results;
9239
9906
  }
9240
- function makeDefaultRqbMapper2({ selection, isFirst, parseJson, parseJsonIfString, rootJsonMappers, arrayModeRoot }, mapColumnValue) {
9907
+ function makeDefaultRqbMapper2({ selection, isFirst, parseJson, parseJsonIfString, rootJsonMappers, arrayModeRoot }) {
9241
9908
  return (rows) => {
9242
9909
  if (isFirst && !rows[0])
9243
9910
  return rows[0];
9244
- return arrayModeRoot ? mapRelationalRowFromArrays2(isFirst ? rows[0] : rows, isFirst, selection, mapColumnValue, parseJson, parseJsonIfString) : mapRelationalRow2(isFirst ? rows[0] : rows, isFirst, selection, mapColumnValue, parseJson, parseJsonIfString, rootJsonMappers);
9911
+ return arrayModeRoot ? mapRelationalRowFromArrays2(isFirst ? rows[0] : rows, isFirst, selection, parseJson, parseJsonIfString) : mapRelationalRow2(isFirst ? rows[0] : rows, isFirst, selection, parseJson, parseJsonIfString, rootJsonMappers);
9245
9912
  };
9246
9913
  }
9247
- function makeJitRqbMapperInner(selection, rowExpr, selectionVar, mapColumnValue, parseJson, parseJsonIfString, useJsonMappers, preFn, counter, accessByIdx) {
9914
+ function makeJitRqbMapperInner(selection, rowExpr, selectionVar, parseJson, parseJsonIfString, useJsonMappers, preFn, counter, accessByIdx) {
9248
9915
  const bodyStmts = [];
9249
9916
  const literalEntries = [];
9250
9917
  let hasWork = false;
@@ -9268,7 +9935,7 @@ function makeJitRqbMapperInner(selection, rowExpr, selectionVar, mapColumnValue,
9268
9935
  preFn.push(`const { selection: ${nestedSelVar} } = ${sel};`);
9269
9936
  if (isArray) {
9270
9937
  const j = `j${counter.n++}`;
9271
- const inner = makeJitRqbMapperInner(innerSelection, `${slot}[${j}]`, nestedSelVar, mapColumnValue, false, parseJsonIfString, true, preFn, counter, false);
9938
+ const inner = makeJitRqbMapperInner(innerSelection, `${slot}[${j}]`, nestedSelVar, false, parseJsonIfString, true, preFn, counter, false);
9272
9939
  if (inner.hasWork) {
9273
9940
  hasWork = true;
9274
9941
  bodyStmts.push(`if (${slot} !== null) {`);
@@ -9281,7 +9948,7 @@ function makeJitRqbMapperInner(selection, rowExpr, selectionVar, mapColumnValue,
9281
9948
  } else
9282
9949
  preFn.splice(savedPreFnLen, 1);
9283
9950
  } else {
9284
- const inner = makeJitRqbMapperInner(innerSelection, slot, nestedSelVar, mapColumnValue, false, parseJsonIfString, true, preFn, counter, false);
9951
+ const inner = makeJitRqbMapperInner(innerSelection, slot, nestedSelVar, false, parseJsonIfString, true, preFn, counter, false);
9285
9952
  if (inner.hasWork) {
9286
9953
  hasWork = true;
9287
9954
  bodyStmts.push(`if (${slot} !== null) {`);
@@ -9310,21 +9977,39 @@ function makeJitRqbMapperInner(selection, rowExpr, selectionVar, mapColumnValue,
9310
9977
  decoderExpr = `dec${id}.mapFromDriverValue`;
9311
9978
  }
9312
9979
  } else if (is(field, SQL)) {
9313
- if (!field.decoder.mapFromDriverValue.isNoop) {
9980
+ if (useJsonMappers && field.decoder.mapFromJsonValue) {
9981
+ bypassCodecs = true;
9982
+ const id = counter.n++;
9983
+ destructure = `field: { decoder: dec${id} }`;
9984
+ decoderExpr = `dec${id}.mapFromJsonValue`;
9985
+ } else if (!field.decoder.mapFromDriverValue.isNoop) {
9314
9986
  const id = counter.n++;
9315
9987
  destructure = `field: { decoder: dec${id} }`;
9316
9988
  decoderExpr = `dec${id}.mapFromDriverValue`;
9317
9989
  }
9318
9990
  } else if (is(field, SQL.Aliased)) {
9319
- if (!field.sql.decoder.mapFromDriverValue.isNoop) {
9991
+ if (useJsonMappers && field.sql.decoder.mapFromJsonValue) {
9992
+ bypassCodecs = true;
9993
+ const id = counter.n++;
9994
+ destructure = `field: { sql: { decoder: dec${id} } }`;
9995
+ decoderExpr = `dec${id}.mapFromJsonValue`;
9996
+ } else if (!field.sql.decoder.mapFromDriverValue.isNoop) {
9320
9997
  const id = counter.n++;
9321
9998
  destructure = `field: { sql: { decoder: dec${id} } }`;
9322
9999
  decoderExpr = `dec${id}.mapFromDriverValue`;
9323
10000
  }
9324
- } else if (is(field, Table) || is(field, View)) {} else if (!field.getSQL().decoder.mapFromDriverValue.isNoop) {
9325
- const id = counter.n++;
9326
- preFn.push(`const dec${id} = ${sel}.field.getSQL().decoder;`);
9327
- decoderExpr = `dec${id}.mapFromDriverValue`;
10001
+ } else if (is(field, Table) || is(field, View)) {} else {
10002
+ const sqlExpr = field.getSQL();
10003
+ if (useJsonMappers && sqlExpr.decoder.mapFromJsonValue) {
10004
+ bypassCodecs = true;
10005
+ const id = counter.n++;
10006
+ preFn.push(`const dec${id} = ${sel}.field.getSQL().decoder;`);
10007
+ decoderExpr = `dec${id}.mapFromJsonValue`;
10008
+ } else if (!sqlExpr.decoder.mapFromDriverValue.isNoop) {
10009
+ const id = counter.n++;
10010
+ preFn.push(`const dec${id} = ${sel}.field.getSQL().decoder;`);
10011
+ decoderExpr = `dec${id}.mapFromDriverValue`;
10012
+ }
9328
10013
  }
9329
10014
  let codecVar = "";
9330
10015
  if (!bypassCodecs && codec)
@@ -9337,19 +10022,7 @@ function makeJitRqbMapperInner(selection, rowExpr, selectionVar, mapColumnValue,
9337
10022
  parts.push(`codec: ${codecVar}`);
9338
10023
  preFn.push(`const { ${parts.join(", ")} } = ${sel};`);
9339
10024
  }
9340
- if (mapColumnValue) {
9341
- hasWork = true;
9342
- bodyStmts.push(`${slot} = mapColumnValue(${slot});`);
9343
- if (decoderExpr || codecVar) {
9344
- let decoded = slot;
9345
- if (codecVar)
9346
- decoded = `${codecVar}(${decoded}, ${arrayDimensions})`;
9347
- if (decoderExpr)
9348
- decoded = `${decoderExpr}(${decoded})`;
9349
- bodyStmts.push(`if (${slot} !== null) ${slot} = ${decoded};`);
9350
- }
9351
- literalEntries.push(`${keyStr}: ${slot}`);
9352
- } else if (decoderExpr || codecVar) {
10025
+ if (decoderExpr || codecVar) {
9353
10026
  hasWork = true;
9354
10027
  let decoded = slot;
9355
10028
  if (codecVar)
@@ -9366,12 +10039,12 @@ function makeJitRqbMapperInner(selection, rowExpr, selectionVar, mapColumnValue,
9366
10039
  hasWork
9367
10040
  };
9368
10041
  }
9369
- function makeJitRqbMapper2({ selection, isFirst, parseJson, parseJsonIfString, rootJsonMappers, arrayModeRoot }, mapColumnValue) {
10042
+ function makeJitRqbMapper2({ selection, isFirst, parseJson, parseJsonIfString, rootJsonMappers, arrayModeRoot }) {
9370
10043
  const preFn = [];
9371
- const inner = makeJitRqbMapperInner(selection, "row", "selection", mapColumnValue, parseJson, parseJsonIfString, arrayModeRoot ? false : rootJsonMappers, preFn, { n: 0 }, !!arrayModeRoot);
10044
+ const inner = makeJitRqbMapperInner(selection, "row", "selection", parseJson, parseJsonIfString, arrayModeRoot ? false : rootJsonMappers, preFn, { n: 0 }, !!arrayModeRoot);
9372
10045
  const lines = [];
9373
10046
  lines.push(` "use strict";
9374
- const { selection${mapColumnValue ? `, mapColumnValue` : ""} } = this;`);
10047
+ const { selection } = this;`);
9375
10048
  for (const p2 of preFn)
9376
10049
  lines.push(` ${p2}`);
9377
10050
  if (arrayModeRoot)
@@ -9413,10 +10086,7 @@ function makeJitRqbMapper2({ selection, isFirst, parseJson, parseJsonIfString, r
9413
10086
  lines.push("\t//# sourceURL=drizzle:jit-relational-query-mapper");
9414
10087
  const compiled = lines.join(`
9415
10088
  `);
9416
- return Object.assign(new FnConstructor2("rows", compiled).bind({
9417
- selection,
9418
- mapColumnValue
9419
- }), { body: `function jitRqbMapper (rows) {
10089
+ return Object.assign(new FnConstructor2("rows", compiled).bind({ selection }), { body: `function jitRqbMapper (rows) {
9420
10090
  ${compiled}
9421
10091
  }` });
9422
10092
  }
@@ -9539,17 +10209,23 @@ function relationsOrderToSQL2(table, orders) {
9539
10209
  return;
9540
10210
  return sql.join(entries.map(([target, value]) => (value === "asc" ? asc : desc)(fieldSelectionToSQL2(table, target))), sql`, `);
9541
10211
  }
9542
- function relationExtrasToSQL2(table, extras) {
10212
+ function relationExtrasToSQL2(table, extras, codecs, inJson) {
9543
10213
  const subqueries = [];
9544
10214
  const selection = [];
9545
10215
  for (const [key, field] of Object.entries(extras)) {
9546
10216
  if (!field)
9547
10217
  continue;
9548
- const extra = typeof field === "function" ? field(table, { sql: operators2.sql }) : field;
9549
- const query = sql`(${extra.getSQL()}) as ${sql.identifier(key)}`;
9550
- query.decoder = extra.getSQL().decoder;
10218
+ const subq = (typeof field === "function" ? field(table, { sql: operators2.sql }) : field).getSQL();
10219
+ const column = codecs ? getColumnFromDecoder2(subq) : undefined;
10220
+ const query = column && (!inJson || !column.jsonSelectIdentifier) ? sql`${codecs.apply(column, inJson ? "castInJson" : "cast", sql`(${subq})`)} as ${sql.identifier(key)}` : sql`(${subq}) as ${sql.identifier(key)}`;
10221
+ query.decoder = subq.decoder;
9551
10222
  subqueries.push(query);
9552
- selection.push({
10223
+ selection.push(column && (!inJson || !column.mapFromJsonValue) ? {
10224
+ key,
10225
+ field: query,
10226
+ codec: codecs.get(column, inJson ? "normalizeInJson" : "normalize"),
10227
+ arrayDimensions: column.dimensions
10228
+ } : {
9553
10229
  key,
9554
10230
  field: query
9555
10231
  });
@@ -9658,43 +10334,58 @@ var PgDialect2 = class {
9658
10334
  }
9659
10335
  buildSelection(fields, { isSingleTable = false, ignoreCastCodecs = false } = {}) {
9660
10336
  const columnsLen = fields.length;
9661
- const chunks = fields.flatMap(({ field }, i) => {
10337
+ const chunks = fields.flatMap(({ field, codecOverride, column }, i) => {
9662
10338
  const chunk = [];
9663
- if (is(field, SQL.Aliased) && field.isSelectionField) {
9664
- if (!isSingleTable && field.origin !== undefined)
9665
- chunk.push(sql.identifier(field.origin), sql.raw("."));
9666
- chunk.push(sql.identifier(field.fieldAlias));
9667
- } else if (is(field, SQL.Aliased) || is(field, SQL)) {
9668
- const query = is(field, SQL.Aliased) ? field.sql : field;
10339
+ const override = codecOverride;
10340
+ if (is(field, SQL.Aliased))
10341
+ if (field.isSelectionField) {
10342
+ const query = !isSingleTable && field.origin !== undefined ? sql`${sql.identifier(field.origin)}.${sql.identifier(field.fieldAlias)}` : sql.identifier(field.fieldAlias);
10343
+ if (column && !ignoreCastCodecs)
10344
+ chunk.push(this.codecs.apply(column, "cast", query, override));
10345
+ else
10346
+ chunk.push(query);
10347
+ } else {
10348
+ const query = field.sql;
10349
+ if (isSingleTable) {
10350
+ const newSql = new SQL(query.queryChunks.map((c) => {
10351
+ if (is(c, PgColumn))
10352
+ return sql.identifier(c.name);
10353
+ return c;
10354
+ }));
10355
+ if (query.shouldInlineParams)
10356
+ newSql.inlineParams();
10357
+ chunk.push(column && !ignoreCastCodecs ? this.codecs.apply(column, "cast", newSql, override) : newSql);
10358
+ } else
10359
+ chunk.push(column && !ignoreCastCodecs ? this.codecs.apply(column, "cast", query, override) : query);
10360
+ chunk.push(sql` as ${sql.identifier(field.fieldAlias)}`);
10361
+ }
10362
+ else if (is(field, SQL)) {
10363
+ const query = field;
9669
10364
  if (isSingleTable) {
9670
10365
  const newSql = new SQL(query.queryChunks.map((c) => {
9671
10366
  if (is(c, PgColumn))
9672
10367
  return sql.identifier(c.name);
9673
10368
  return c;
9674
10369
  }));
9675
- chunk.push(query.shouldInlineParams ? newSql.inlineParams() : newSql);
10370
+ if (query.shouldInlineParams)
10371
+ newSql.inlineParams();
10372
+ chunk.push(column && !ignoreCastCodecs ? this.codecs.apply(column, "cast", newSql, override) : newSql);
9676
10373
  } else
9677
- chunk.push(query);
9678
- if (is(field, SQL.Aliased))
9679
- chunk.push(sql` as ${sql.identifier(field.fieldAlias)}`);
10374
+ chunk.push(column && !ignoreCastCodecs ? this.codecs.apply(column, "cast", query, override) : query);
9680
10375
  } else if (is(field, Column)) {
9681
10376
  let name2;
9682
10377
  if (isSingleTable)
9683
10378
  name2 = field.isAlias ? sql.identifier(getOriginalColumnFromAlias2(field).name) : sql.identifier(field.name);
9684
10379
  else
9685
10380
  name2 = field.isAlias ? getOriginalColumnFromAlias2(field) : field;
9686
- const casted = ignoreCastCodecs ? name2 : this.codecs.apply(field, "cast", name2);
10381
+ const casted = ignoreCastCodecs ? name2 : this.codecs.apply(field, "cast", name2, override);
9687
10382
  chunk.push(field.isAlias ? sql`${casted} as ${field}` : casted);
9688
- } else if (is(field, Subquery)) {
9689
- const entries = Object.entries(field._.selectedFields);
9690
- if (entries.length === 1) {
9691
- const entry = entries[0][1];
9692
- const fieldDecoder = is(entry, SQL) ? entry.decoder : is(entry, Column) ? { mapFromDriverValue: (v2) => entry.mapFromDriverValue(v2) } : entry.sql.decoder;
9693
- if (fieldDecoder)
9694
- field._.sql.decoder = fieldDecoder;
9695
- }
9696
- chunk.push(field);
9697
- }
10383
+ } else if (is(field, Subquery))
10384
+ if (column && !ignoreCastCodecs && !field._.isWith) {
10385
+ const innerCasted = this.codecs.apply(column, "cast", sql`(${field._.sql})`, override);
10386
+ chunk.push(sql`${innerCasted} ${sql.identifier(field._.alias)}`);
10387
+ } else
10388
+ chunk.push(column ? this.codecs.apply(column, "cast", field) : field, override);
9698
10389
  if (i < columnsLen - 1)
9699
10390
  chunk.push(sql`, `);
9700
10391
  return chunk;
@@ -9745,8 +10436,10 @@ var PgDialect2 = class {
9745
10436
  }
9746
10437
  return table;
9747
10438
  }
9748
- buildSelectQuery({ withList, fields, fieldsFlat, where, having, table, joins, orderBy, groupBy, limit, offset, lockingClause, distinct, setOperators, comment, ignoreSelectionCastCodecs }) {
9749
- const fieldsList = fieldsFlat ?? orderSelectedFields2(fields, undefined, this.codecs);
10439
+ buildSelectQuery({ withList, fieldsFlat, where, having, table, joins, orderBy, groupBy, limit, offset, lockingClause, distinct, setOperators, comment, ignoreSelectionCastCodecs }) {
10440
+ if (!fieldsFlat)
10441
+ throw new Error("Select query builder must be provided with `fieldsFlat` on `buildSelectQuery` invocation");
10442
+ const fieldsList = fieldsFlat;
9750
10443
  for (const f of fieldsList)
9751
10444
  if (is(f.field, Column) && getTableName(f.field.table) !== (is(table, Subquery) ? table._.alias : is(table, PgViewBase) ? table[ViewBaseConfig].name : is(table, SQL) ? undefined : getTableName(table)) && !((table2) => joins?.some(({ alias: alias2 }) => alias2 === (table2[Table.Symbol.IsAlias] ? getTableName(table2) : table2[Table.Symbol.BaseName])))(f.field.table)) {
9752
10445
  const tableName = getTableName(f.field.table);
@@ -9759,7 +10452,7 @@ var PgDialect2 = class {
9759
10452
  distinctSql = distinct === true ? sql` distinct` : sql` distinct on (${sql.join(distinct.on, sql`, `)})`;
9760
10453
  const selection = this.buildSelection(fieldsList, {
9761
10454
  isSingleTable,
9762
- ignoreCastCodecs: ignoreSelectionCastCodecs
10455
+ ignoreCastCodecs: ignoreSelectionCastCodecs || setOperators.length > 0
9763
10456
  });
9764
10457
  const tableSql = this.buildFromTable(table);
9765
10458
  const joinsSql = this.buildJoins(joins);
@@ -9786,26 +10479,67 @@ var PgDialect2 = class {
9786
10479
  }
9787
10480
  const finalQuery = sql`${withSql}select${distinctSql} ${selection} from ${tableSql}${joinsSql}${whereSql}${groupBySql}${havingSql}${orderBySql}${limitSql}${offsetSql}${lockingClauseSql}${comment !== undefined ? sql` ${comment}` : undefined}`;
9788
10481
  if (setOperators.length > 0)
9789
- return this.buildSetOperations(finalQuery, setOperators);
10482
+ return this.buildSetOperations(finalQuery, fieldsList, ignoreSelectionCastCodecs, setOperators);
9790
10483
  return finalQuery;
9791
10484
  }
9792
- buildSetOperations(leftSelect, setOperators) {
9793
- const [setOperator, ...rest] = setOperators;
9794
- if (!setOperator)
9795
- throw new Error("Cannot pass undefined values to any set operator");
9796
- if (rest.length === 0)
9797
- return this.buildSetOperationQuery({
10485
+ buildSetOperations(leftSelect, leftSelection, ignoreSelectionCastCodecs, setOperators) {
10486
+ const outputSelection = leftSelection;
10487
+ for (let i = 0;i < setOperators.length; ++i) {
10488
+ const setOperator = setOperators[i];
10489
+ if (!setOperator)
10490
+ throw new Error("Cannot pass undefined values to any set operator");
10491
+ leftSelect = this.buildSetOperationQuery({
9798
10492
  leftSelect,
9799
10493
  setOperator
9800
10494
  });
9801
- return this.buildSetOperations(this.buildSetOperationQuery({
9802
- leftSelect,
9803
- setOperator
9804
- }), rest);
10495
+ const rightSelection = orderSelectedFields2(setOperator.rightSelect.getSelectedFields());
10496
+ for (let j = 0;j < outputSelection.length; ++j) {
10497
+ const l = outputSelection[j];
10498
+ const lPath = l.path.join(".");
10499
+ const r = rightSelection.find((e) => e.path.join(".") === lPath);
10500
+ const lc = l.codecOverride ?? l.column?.codec;
10501
+ const rc = r.codecOverride ?? r.column?.codec;
10502
+ outputSelection[j].codecOverride = lc && rc ? unionsTypeTable[lc]?.[rc] : lc;
10503
+ }
10504
+ }
10505
+ for (let i = 0;i < outputSelection.length; ++i) {
10506
+ const out = outputSelection[i];
10507
+ out.codec = out.codecOverride ? this.codecs.get(out.column, "normalize", out.codecOverride) : out.codec;
10508
+ }
10509
+ return ignoreSelectionCastCodecs ? leftSelect : sql`select ${this.buildSelection(outputSelection.map((field) => {
10510
+ if (is(field.field, SQL.Aliased)) {
10511
+ const ref = field.field.clone();
10512
+ ref.isSelectionField = true;
10513
+ return {
10514
+ ...field,
10515
+ field: ref
10516
+ };
10517
+ }
10518
+ if (is(field.field, Column) && field.field.isAlias) {
10519
+ const ref = new SQL.Aliased(sql`${sql.identifier(field.field.name)}`, field.field.name);
10520
+ ref.isSelectionField = true;
10521
+ return {
10522
+ ...field,
10523
+ field: ref
10524
+ };
10525
+ }
10526
+ if (is(field.field, Subquery)) {
10527
+ const ref = new SQL.Aliased(sql`${field.field.getSQL()}`, field.field._.alias);
10528
+ ref.isSelectionField = true;
10529
+ return {
10530
+ ...field,
10531
+ field: ref
10532
+ };
10533
+ }
10534
+ return field;
10535
+ }), {
10536
+ isSingleTable: true,
10537
+ ignoreCastCodecs: ignoreSelectionCastCodecs
10538
+ })} from (${leftSelect}) ${sql.identifier("drizzle_union")}`;
9805
10539
  }
9806
10540
  buildSetOperationQuery({ leftSelect, setOperator: { type, isAll, rightSelect, limit, orderBy, offset } }) {
9807
10541
  const leftChunk = sql`(${leftSelect.getSQL()}) `;
9808
- const rightChunk = sql`(${rightSelect.getSQL()})`;
10542
+ const rightChunk = sql`(${rightSelect.withoutSelectionCastCodecs().getSQL()})`;
9809
10543
  let orderBySql;
9810
10544
  if (orderBy && orderBy.length > 0) {
9811
10545
  const orderByValues = [];
@@ -9831,8 +10565,9 @@ var PgDialect2 = class {
9831
10565
  buildInsertQuery({ table, values: valuesOrSelect, onConflict, returning, withList, select, overridingSystemValue_, comment, ignoreSelectionCastCodecs }) {
9832
10566
  const valuesSqlList = [];
9833
10567
  const columns = table[Table.Symbol.Columns];
9834
- const colEntries = Object.entries(columns).filter(([_, col]) => !col.shouldDisableInsert());
9835
- const insertOrder = colEntries.map(([, column]) => sql.identifier(column.name));
10568
+ const colEntries = Object.entries(columns);
10569
+ const colFilteredEntries = select && !is(valuesOrSelect, SQL) ? Object.keys(valuesOrSelect.getSelectedFields()).map((key) => [key, columns[key]]) : overridingSystemValue_ ? colEntries : colEntries.filter(([_, col]) => !col.shouldDisableInsert());
10570
+ const insertOrder = colFilteredEntries.map(([, column]) => sql.identifier(column.name));
9836
10571
  if (select) {
9837
10572
  const select2 = valuesOrSelect;
9838
10573
  if (is(select2, SQL))
@@ -9844,7 +10579,7 @@ var PgDialect2 = class {
9844
10579
  valuesSqlList.push(sql.raw("values "));
9845
10580
  for (const [valueIndex, value] of values.entries()) {
9846
10581
  const valueList = [];
9847
- for (const [fieldName, col] of colEntries) {
10582
+ for (const [fieldName, col] of colFilteredEntries) {
9848
10583
  const colValue = value[fieldName];
9849
10584
  if (colValue === undefined || is(colValue, Param) && colValue.value === undefined)
9850
10585
  if (col.defaultFn !== undefined) {
@@ -9895,31 +10630,48 @@ var PgDialect2 = class {
9895
10630
  tagged: true
9896
10631
  });
9897
10632
  }
9898
- nestedSelectionerror() {
10633
+ buildRqbColumn(table, field, key, inJson) {
10634
+ if (is(field, Column)) {
10635
+ const name2 = sql`${table}.${sql.identifier(field.name)}`;
10636
+ return sql`${inJson && field.jsonSelectIdentifier ? field.jsonSelectIdentifier(name2, sql, field.dimensions) : this.codecs.apply(field, inJson ? "castInJson" : "cast", name2)} as ${sql.identifier(key)}`;
10637
+ }
10638
+ if (is(field, SQL.Aliased)) {
10639
+ const column = getColumnFromDecoder2(field);
10640
+ const q = sql`${table}.${sql.identifier(field.fieldAlias)}`;
10641
+ return sql`${column ? this.codecs.apply(column, inJson ? "castInJson" : "cast", q) : q} as ${sql.identifier(key)}`;
10642
+ }
10643
+ if (isSQLWrapper(field)) {
10644
+ const column = getColumnFromDecoder2(field);
10645
+ const q = sql`${table}.${sql.identifier(key)}`;
10646
+ return sql`${column ? this.codecs.apply(column, inJson ? "castInJson" : "cast", q) : q} as ${sql.identifier(key)}`;
10647
+ }
9899
10648
  throw new DrizzleError2({ message: `Views with nested selections are not supported by the relational query builder` });
9900
10649
  }
9901
- buildRqbColumn(table, column, key, inJson) {
9902
- if (is(column, Column)) {
9903
- const name2 = sql`${table}.${sql.identifier(column.name)}`;
9904
- return sql`${inJson && column.jsonSelectIdentifier ? column.jsonSelectIdentifier(name2, sql, column.dimensions) : this.codecs.apply(column, inJson ? "castInJson" : "cast", name2)} as ${sql.identifier(key)}`;
9905
- }
9906
- return sql`${table}.${is(column, SQL.Aliased) ? sql.identifier(column.fieldAlias) : isSQLWrapper(column) ? sql.identifier(key) : this.nestedSelectionerror()} as ${sql.identifier(key)}`;
10650
+ resolveSelection(field, key, inJson) {
10651
+ if (is(field, Column))
10652
+ return {
10653
+ key,
10654
+ field,
10655
+ codec: this.codecs.get(field, inJson ? "normalizeInJson" : "normalize"),
10656
+ arrayDimensions: field.dimensions
10657
+ };
10658
+ const decoderColumn = getColumnFromDecoder2(field);
10659
+ return decoderColumn ? {
10660
+ key,
10661
+ field,
10662
+ codec: decoderColumn && (!inJson || !decoderColumn.mapFromJsonValue) ? this.codecs.get(decoderColumn, inJson ? "normalizeInJson" : "normalize") : undefined,
10663
+ arrayDimensions: decoderColumn.dimensions
10664
+ } : {
10665
+ key,
10666
+ field
10667
+ };
9907
10668
  }
9908
- unwrapAllColumns = (table, selection, inJson) => {
9909
- return sql.join(Object.entries(table[TableColumns]).map(([k, v2]) => {
9910
- selection.push(is(v2, Column) ? {
9911
- key: k,
9912
- codec: this.codecs.get(v2, inJson ? "normalizeInJson" : "normalize"),
9913
- arrayDimensions: v2.dimensions,
9914
- field: v2
9915
- } : {
9916
- key: k,
9917
- field: v2
9918
- });
9919
- return this.buildRqbColumn(table, v2, k, inJson);
9920
- }), sql`, `);
9921
- };
9922
- buildColumns = (table, selection, inJson, config) => config?.columns ? (() => {
10669
+ buildColumns = (table, selection, inJson, config) => {
10670
+ if (!config?.columns)
10671
+ return sql.join(Object.entries(table[TableColumns]).map(([k, v2]) => {
10672
+ selection.push(this.resolveSelection(v2, k, inJson));
10673
+ return this.buildRqbColumn(table, v2, k, inJson);
10674
+ }), sql`, `);
9923
10675
  const entries = Object.entries(config.columns);
9924
10676
  const columnContainer = table[TableColumns];
9925
10677
  const columnIdentifiers = [];
@@ -9931,15 +10683,7 @@ var PgDialect2 = class {
9931
10683
  if (v2) {
9932
10684
  const column = columnContainer[k];
9933
10685
  columnIdentifiers.push(this.buildRqbColumn(table, column, k, inJson));
9934
- selection.push(is(column, Column) ? {
9935
- key: k,
9936
- codec: this.codecs.get(column, inJson ? "normalizeInJson" : "normalize"),
9937
- arrayDimensions: column.dimensions,
9938
- field: column
9939
- } : {
9940
- key: k,
9941
- field: column
9942
- });
10686
+ selection.push(this.resolveSelection(column, k, inJson));
9943
10687
  }
9944
10688
  }
9945
10689
  if (colSelectionMode === false)
@@ -9947,18 +10691,10 @@ var PgDialect2 = class {
9947
10691
  if (config.columns[k] === false)
9948
10692
  continue;
9949
10693
  columnIdentifiers.push(this.buildRqbColumn(table, v2, k, inJson));
9950
- selection.push(is(v2, Column) ? {
9951
- key: k,
9952
- codec: this.codecs.get(v2, inJson ? "normalizeInJson" : "normalize"),
9953
- arrayDimensions: v2.dimensions,
9954
- field: v2
9955
- } : {
9956
- key: k,
9957
- field: v2
9958
- });
10694
+ selection.push(this.resolveSelection(v2, k, inJson));
9959
10695
  }
9960
10696
  return columnIdentifiers.length ? sql.join(columnIdentifiers, sql`, `) : undefined;
9961
- })() : this.unwrapAllColumns(table, selection, inJson);
10697
+ };
9962
10698
  buildRelationalQuery({ schema, table, tableConfig, queryConfig: config, relationWhere, mode, errorPath, depth, throughJoin, nested }) {
9963
10699
  const selection = [];
9964
10700
  const isSingle = mode === "first";
@@ -9972,7 +10708,7 @@ var PgDialect2 = class {
9972
10708
  const where = params?.where && relationWhere ? and(relationsFilterToSQL2(table, params.where, tableConfig.relations, schema), relationWhere) : params?.where ? relationsFilterToSQL2(table, params.where, tableConfig.relations, schema) : relationWhere;
9973
10709
  const order = params?.orderBy ? relationsOrderToSQL2(table, params.orderBy) : undefined;
9974
10710
  const columns = this.buildColumns(table, selection, !!nested, params);
9975
- const extras = params?.extras ? relationExtrasToSQL2(table, params.extras) : undefined;
10711
+ const extras = params?.extras ? relationExtrasToSQL2(table, params.extras, this.codecs, nested) : undefined;
9976
10712
  if (extras)
9977
10713
  selection.push(...extras.selection);
9978
10714
  const selectionArr = columns ? [columns] : [];
@@ -10122,11 +10858,6 @@ var PgInsertBuilder2 = class {
10122
10858
  this.overridingSystemValue_ = overridingSystemValue_;
10123
10859
  this.builder = builder;
10124
10860
  }
10125
- authToken;
10126
- setToken(token) {
10127
- this.authToken = token;
10128
- return this;
10129
- }
10130
10861
  overridingSystemValue() {
10131
10862
  this.overridingSystemValue_ = true;
10132
10863
  return this;
@@ -10144,27 +10875,25 @@ var PgInsertBuilder2 = class {
10144
10875
  }
10145
10876
  return result;
10146
10877
  });
10147
- const builder = new this.builder(this.table, mappedValues, this.session, this.dialect, this.withList, false, this.overridingSystemValue_);
10148
- if ("setToken" in builder)
10149
- builder.setToken(this.authToken);
10150
- return builder;
10878
+ return new this.builder(this.table, mappedValues, this.session, this.dialect, this.withList, false, this.overridingSystemValue_);
10151
10879
  }
10152
10880
  select(selectQuery) {
10153
10881
  const select = typeof selectQuery === "function" ? selectQuery(new QueryBuilder2) : selectQuery;
10154
10882
  if ("withoutSelectionCastCodecs" in select)
10155
10883
  select.withoutSelectionCastCodecs();
10156
- if (!is(select, SQL) && !haveSameKeys2(this.table[TableColumns], select._.selectedFields))
10157
- throw new Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");
10158
- const builder = new this.builder(this.table, select, this.session, this.dialect, this.withList, true);
10159
- if ("setToken" in builder)
10160
- builder.setToken(this.authToken);
10161
- return builder;
10884
+ if (!is(select, SQL)) {
10885
+ const insertCols = Object.keys(this.table[Table.Symbol.Columns]);
10886
+ const selected = Object.keys(select._.selectedFields);
10887
+ for (const col of selected)
10888
+ if (!insertCols.includes(col))
10889
+ throw new Error(`Insert select error: column "${col}" does not exist in table "${this.table[Table.Symbol.Name]}"`);
10890
+ }
10891
+ return new this.builder(this.table, select, this.session, this.dialect, this.withList, true, this.overridingSystemValue_);
10162
10892
  }
10163
10893
  };
10164
10894
  var PgInsertBase2 = class {
10165
10895
  static [entityKind] = "PgInsert";
10166
10896
  config;
10167
- cacheConfig;
10168
10897
  constructor(table, values, session, dialect, withList, select, overridingSystemValue_) {
10169
10898
  this.session = session;
10170
10899
  this.dialect = dialect;
@@ -10234,7 +10963,7 @@ var PgInsertBase2 = class {
10234
10963
  var PgAsyncInsertBase2 = class extends PgInsertBase2 {
10235
10964
  static [entityKind] = "PgAsyncInsert";
10236
10965
  _prepare(name2, generateName = false) {
10237
- const { session, config, dialect, cacheConfig } = this;
10966
+ const { session, config, dialect } = this;
10238
10967
  const { returning: fields } = config;
10239
10968
  return tracer.startActiveSpan("drizzle.prepareQuery", () => {
10240
10969
  const query = dialect.sqlToQuery(this.getSQL());
@@ -10242,7 +10971,7 @@ var PgAsyncInsertBase2 = class extends PgInsertBase2 {
10242
10971
  return session.prepareQuery(query, fields ? "arrays" : "raw", name2 ?? generateName, mapper, {
10243
10972
  type: "insert",
10244
10973
  tables: [...extractUsedTable(this.config.table)]
10245
- }, cacheConfig);
10974
+ });
10246
10975
  });
10247
10976
  }
10248
10977
  prepare(name2) {
@@ -10287,10 +11016,10 @@ applyMixins2(PgAsyncRelationalQuery2, [QueryPromise2]);
10287
11016
  // node_modules/drizzle-orm/pg-core/query-builders/raw.js
10288
11017
  var PgRaw = class {
10289
11018
  static [entityKind] = "PgRaw";
10290
- constructor(sql2, query, mapBatchResult) {
11019
+ constructor(prepared, sql2, query) {
11020
+ this.prepared = prepared;
10291
11021
  this.sql = sql2;
10292
11022
  this.query = query;
10293
- this.mapBatchResult = mapBatchResult;
10294
11023
  }
10295
11024
  getSQL() {
10296
11025
  return this.sql;
@@ -10298,20 +11027,22 @@ var PgRaw = class {
10298
11027
  getQuery() {
10299
11028
  return this.query;
10300
11029
  }
10301
- mapResult(result, isFromBatch) {
10302
- return isFromBatch ? this.mapBatchResult(result) : result;
11030
+ _prepare() {
11031
+ return this.prepared;
10303
11032
  }
10304
11033
  };
10305
11034
 
10306
11035
  // node_modules/drizzle-orm/pg-core/async/raw.js
10307
11036
  var PgAsyncRaw2 = class extends PgRaw {
10308
11037
  static [entityKind] = "PgAsyncRaw";
10309
- constructor(execute, sql2, query, mapBatchResult) {
10310
- super(sql2, query, mapBatchResult);
10311
- this.execute = execute;
11038
+ constructor(prepared, sql2, query) {
11039
+ super(prepared, sql2, query);
11040
+ }
11041
+ execute(placeholderValues) {
11042
+ return this.prepared.execute(placeholderValues);
10312
11043
  }
10313
11044
  _prepare() {
10314
- return this;
11045
+ return this.prepared;
10315
11046
  }
10316
11047
  };
10317
11048
  applyMixins2(PgAsyncRaw2, [QueryPromise2]);
@@ -10369,12 +11100,11 @@ applyMixins2(PgAsyncRefreshMaterializedView2, [QueryPromise2]);
10369
11100
  var PgAsyncSelectBase2 = class extends PgSelectBase2 {
10370
11101
  static [entityKind] = "PgAsyncSelectQueryBuilder";
10371
11102
  _prepare(name2, generateName = false) {
10372
- const { session, config, dialect, joinsNotNullableMap, cacheConfig, usedTables } = this;
10373
- const { fields } = config;
11103
+ const { session, dialect, cacheConfig, usedTables } = this;
10374
11104
  return tracer.startActiveSpan("drizzle.prepareQuery", () => {
10375
- const query = this.config._tagged ? dialect._sqlToQuery(this.getSQL()) : dialect.sqlToQuery(this.getSQL());
10376
- const fieldsList = orderSelectedFields2(fields, undefined, this.dialect.codecs);
10377
- const mapper = this.dialect.mapperGenerators.rows(fieldsList, joinsNotNullableMap);
11105
+ const query = this.config.tagged ? dialect._sqlToQuery(this.getSQL()) : dialect.sqlToQuery(this.getSQL());
11106
+ const fieldsList = this.config.fieldsFlat;
11107
+ const mapper = this.dialect.mapperGenerators.rows(fieldsList, this.joinsNotNullableMap);
10378
11108
  return session.prepareQuery(query, "arrays", name2 ?? generateName, mapper, {
10379
11109
  type: "select",
10380
11110
  tables: [...usedTables]
@@ -10402,16 +11132,8 @@ var PgUpdateBuilder2 = class {
10402
11132
  this.withList = withList;
10403
11133
  this.builder = builder;
10404
11134
  }
10405
- authToken;
10406
- setToken(token) {
10407
- this.authToken = token;
10408
- return this;
10409
- }
10410
11135
  set(values) {
10411
- const builder = new this.builder(this.table, mapUpdateSet2(this.table, values), this.session, this.dialect, this.withList);
10412
- if ("setToken" in builder)
10413
- builder.setToken(this.authToken);
10414
- return builder;
11136
+ return new this.builder(this.table, mapUpdateSet2(this.table, values), this.session, this.dialect, this.withList);
10415
11137
  }
10416
11138
  };
10417
11139
  var PgUpdateBase2 = class {
@@ -10419,7 +11141,6 @@ var PgUpdateBase2 = class {
10419
11141
  config;
10420
11142
  tableName;
10421
11143
  joinsNotNullableMap;
10422
- cacheConfig;
10423
11144
  constructor(table, set, session, dialect, withList) {
10424
11145
  this.session = session;
10425
11146
  this.dialect = dialect;
@@ -10548,7 +11269,7 @@ var PgUpdateBase2 = class {
10548
11269
  var PgAsyncUpdateBase2 = class extends PgUpdateBase2 {
10549
11270
  static [entityKind] = "PgAsyncUpdate";
10550
11271
  _prepare(name2, generateName = false) {
10551
- const { session, config, dialect, joinsNotNullableMap, cacheConfig } = this;
11272
+ const { session, config, dialect, joinsNotNullableMap } = this;
10552
11273
  const { returning: fields } = config;
10553
11274
  return tracer.startActiveSpan("drizzle.prepareQuery", () => {
10554
11275
  const query = dialect.sqlToQuery(this.getSQL());
@@ -10556,7 +11277,7 @@ var PgAsyncUpdateBase2 = class extends PgUpdateBase2 {
10556
11277
  return session.prepareQuery(query, fields ? "arrays" : "raw", name2 ?? generateName, mapper, {
10557
11278
  type: "update",
10558
11279
  tables: [...extractUsedTable(this.config.table)]
10559
- }, cacheConfig);
11280
+ });
10560
11281
  });
10561
11282
  }
10562
11283
  prepare(name2) {
@@ -10696,8 +11417,7 @@ var PgAsyncDatabase2 = class {
10696
11417
  execute(query) {
10697
11418
  const sequel = typeof query === "string" ? sql.raw(query) : query.getSQL();
10698
11419
  const builtQuery = this.dialect.sqlToQuery(sequel);
10699
- const prepared = this.session.prepareQuery(builtQuery, "raw", false);
10700
- return new PgAsyncRaw2(() => prepared.execute(), sequel, builtQuery, (result) => prepared.mapResult(result, true));
11420
+ return new PgAsyncRaw2(this.session.prepareQuery(builtQuery, "raw", false), sequel, builtQuery);
10701
11421
  }
10702
11422
  transaction(transaction, config) {
10703
11423
  return this.session.transaction(transaction, config);
@@ -10710,9 +11430,6 @@ var PgBasePreparedQuery2 = class {
10710
11430
  constructor(query) {
10711
11431
  this.query = query;
10712
11432
  }
10713
- mapResult(_, __) {
10714
- throw new Error("Method not implemented.");
10715
- }
10716
11433
  getQuery() {
10717
11434
  return this.query;
10718
11435
  }
@@ -11454,5 +12171,5 @@ export {
11454
12171
  createNeonAuthorizationCodeStore
11455
12172
  };
11456
12173
 
11457
- //# debugId=7E900DCFB0BEE85764756E2164756E21
12174
+ //# debugId=84ADA662658B454564756E2164756E21
11458
12175
  //# sourceMappingURL=index.js.map