@absolutejs/auth 0.56.8 → 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.
package/dist/server.js CHANGED
@@ -12763,6 +12763,9 @@ var SQL = class SQL2 {
12763
12763
  this.decoder = typeof decoder === "function" ? { mapFromDriverValue: decoder } : decoder;
12764
12764
  return this;
12765
12765
  }
12766
+ nullable() {
12767
+ return this;
12768
+ }
12766
12769
  inlineParams() {
12767
12770
  this.shouldInlineParams = true;
12768
12771
  return this;
@@ -12948,9 +12951,10 @@ function fillPlaceholders(params, values) {
12948
12951
  if (is(p, Param) && is(p.value, Placeholder)) {
12949
12952
  if (!(p.value.name in values))
12950
12953
  throw new Error(`No value for placeholder "${p.value.name}" was provided`);
12951
- if (values[p.value.name] === null)
12952
- return values[p.value.name];
12953
- const mapped = p.encoder.mapToDriverValue.isNoop ? values[p.value.name] : p.encoder.mapToDriverValue(values[p.value.name]);
12954
+ const value = values[p.value.name];
12955
+ if (value === null)
12956
+ return value;
12957
+ const mapped = p.encoder.mapToDriverValue.isNoop ? value : p.encoder.mapToDriverValue(value);
12954
12958
  return p.codec ? p.codec(mapped) : mapped;
12955
12959
  }
12956
12960
  return p;
@@ -13320,6 +13324,9 @@ var PgColumn = class extends Column {
13320
13324
  }
13321
13325
  return this;
13322
13326
  }
13327
+ shouldDisableInsert() {
13328
+ return this.config.generatedIdentity !== undefined && this.config.generatedIdentity.type !== "byDefault" || this.config.generated !== undefined && this.config.generated.type !== "byDefault";
13329
+ }
13323
13330
  mapArrayElements(value, mapper, depth) {
13324
13331
  if (depth > 0 && Array.isArray(value))
13325
13332
  return value.map((v) => v === null ? null : this.mapArrayElements(v, mapper, depth - 1));
@@ -13585,20 +13592,59 @@ function orderSelectedFields2(fields, pathPrefix, codecs) {
13585
13592
  path: newPath,
13586
13593
  field,
13587
13594
  codec: codecs?.get(field, "normalize"),
13588
- arrayDimensions: field.dimensions
13595
+ arrayDimensions: field.dimensions,
13596
+ column: field
13589
13597
  });
13590
- else if (is(field, Column) || is(field, SQL) || is(field, SQL.Aliased) || is(field, Subquery))
13591
- result.push({
13598
+ else if (is(field, SQL) || is(field, SQL.Aliased)) {
13599
+ const col = getColumnFromDecoder2(field);
13600
+ result.push(col ? {
13601
+ path: newPath,
13602
+ field,
13603
+ codec: codecs?.get(col, "normalize"),
13604
+ arrayDimensions: col.dimensions,
13605
+ column: col
13606
+ } : {
13607
+ path: newPath,
13608
+ field
13609
+ });
13610
+ } else if (is(field, Subquery)) {
13611
+ let column;
13612
+ const entry = Object.values(field._.selectedFields)[0];
13613
+ let fieldDecoder;
13614
+ if (is(entry, Column)) {
13615
+ column = entry;
13616
+ fieldDecoder = entry;
13617
+ } else if (is(entry, SQL)) {
13618
+ column = getColumnFromDecoder2(entry);
13619
+ fieldDecoder = entry.decoder;
13620
+ } else {
13621
+ column = getColumnFromDecoder2(entry);
13622
+ fieldDecoder = entry.sql.decoder;
13623
+ }
13624
+ if (fieldDecoder)
13625
+ field._.sql.decoder = fieldDecoder;
13626
+ result.push(column ? {
13627
+ path: newPath,
13628
+ field,
13629
+ codec: codecs?.get(column, "normalize"),
13630
+ arrayDimensions: column.dimensions,
13631
+ column
13632
+ } : {
13592
13633
  path: newPath,
13593
13634
  field
13594
13635
  });
13595
- else if (is(field, Table))
13636
+ } else if (is(field, Table))
13596
13637
  result.push(...orderSelectedFields2(field[Table.Symbol.Columns], newPath, codecs));
13597
13638
  else
13598
13639
  result.push(...orderSelectedFields2(field, newPath, codecs));
13599
13640
  return result;
13600
13641
  }, []);
13601
13642
  }
13643
+ function getColumnFromDecoder2(source) {
13644
+ const query = source.getSQL();
13645
+ if (is(query.decoder, Column))
13646
+ return query.decoder;
13647
+ }
13602
13648
  function haveSameKeys2(left, right) {
13603
13649
  const leftKeys = Object.keys(left);
13604
13650
  const rightKeys = Object.keys(right);
@@ -13742,481 +13788,169 @@ var PgBoolean = class extends PgColumn {
13742
13788
  function boolean(name2) {
13743
13789
  return new PgBooleanBuilder(name2 ?? "");
13744
13790
  }
13745
- // node_modules/drizzle-orm/pg-core/columns/double-precision.js
13746
- var PgDoublePrecisionBuilder = class extends PgColumnBuilder {
13747
- static [entityKind] = "PgDoublePrecisionBuilder";
13748
- constructor(name2) {
13749
- super(name2, "number double", "PgDoublePrecision");
13750
- }
13751
- build(table) {
13752
- return new PgDoublePrecision(table, this.config);
13753
- }
13754
- };
13755
- var PgDoublePrecision = class extends PgColumn {
13756
- static [entityKind] = "PgDoublePrecision";
13757
- codec = "float8";
13758
- getSQLType() {
13759
- return "double precision";
13791
+ // node_modules/drizzle-orm/pg-core/array.js
13792
+ function parsePgArrayValue(arrayString, startFrom, inQuotes) {
13793
+ for (let i = startFrom;i < arrayString.length; i++) {
13794
+ const char = arrayString[i];
13795
+ if (char === "\\") {
13796
+ i++;
13797
+ continue;
13798
+ }
13799
+ if (char === '"')
13800
+ return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i + 1];
13801
+ if (inQuotes)
13802
+ continue;
13803
+ if (char === "," || char === "}")
13804
+ return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i];
13760
13805
  }
13761
- };
13762
- function doublePrecision(name2) {
13763
- return new PgDoublePrecisionBuilder(name2 ?? "");
13806
+ return [arrayString.slice(startFrom).replace(/\\/g, ""), arrayString.length];
13764
13807
  }
13765
- // node_modules/drizzle-orm/pg-core/columns/integer.js
13766
- var PgIntegerBuilder = class extends PgIntColumnBuilder {
13767
- static [entityKind] = "PgIntegerBuilder";
13768
- constructor(name2) {
13769
- super(name2, "number int32", "PgInteger");
13770
- }
13771
- build(table) {
13772
- return new PgInteger(table, this.config);
13773
- }
13774
- };
13775
- var PgInteger = class extends PgColumn {
13776
- static [entityKind] = "PgInteger";
13777
- codec = "int";
13778
- getSQLType() {
13779
- return "integer";
13808
+ function parsePgNestedArray(arrayString, startFrom = 0) {
13809
+ const result = [];
13810
+ let i = startFrom;
13811
+ let lastCharIsComma = false;
13812
+ while (i < arrayString.length) {
13813
+ const char = arrayString[i];
13814
+ if (char === ",") {
13815
+ if (lastCharIsComma || i === startFrom)
13816
+ result.push("");
13817
+ lastCharIsComma = true;
13818
+ i++;
13819
+ continue;
13820
+ }
13821
+ lastCharIsComma = false;
13822
+ if (char === "\\") {
13823
+ i += 2;
13824
+ continue;
13825
+ }
13826
+ if (char === '"') {
13827
+ const [value2, startFrom2] = parsePgArrayValue(arrayString, i + 1, true);
13828
+ result.push(value2);
13829
+ i = startFrom2;
13830
+ continue;
13831
+ }
13832
+ if (char === "}")
13833
+ return [result, i + 1];
13834
+ if (char === "{") {
13835
+ const [value2, startFrom2] = parsePgNestedArray(arrayString, i + 1);
13836
+ result.push(value2);
13837
+ i = startFrom2;
13838
+ continue;
13839
+ }
13840
+ const [value, newStartFrom] = parsePgArrayValue(arrayString, i, false);
13841
+ result.push(value);
13842
+ i = newStartFrom;
13780
13843
  }
13781
- };
13782
- function integer(name2) {
13783
- return new PgIntegerBuilder(name2 ?? "");
13844
+ return [result, i];
13784
13845
  }
13785
- // node_modules/drizzle-orm/pg-core/columns/jsonb.js
13786
- var PgJsonbBuilder = class extends PgColumnBuilder {
13787
- static [entityKind] = "PgJsonbBuilder";
13788
- constructor(name2) {
13789
- super(name2, "object json", "PgJsonb");
13790
- }
13791
- build(table) {
13792
- return new PgJsonb(table, this.config);
13793
- }
13794
- };
13795
- var PgJsonb = class extends PgColumn {
13796
- static [entityKind] = "PgJsonb";
13797
- codec = "jsonb";
13798
- constructor(table, config) {
13799
- super(table, config);
13800
- }
13801
- getSQLType() {
13802
- return "jsonb";
13803
- }
13804
- };
13805
- function jsonb(name2) {
13806
- return new PgJsonbBuilder(name2 ?? "");
13846
+ function parsePgArray(arrayString) {
13847
+ const [result] = parsePgNestedArray(arrayString, 1);
13848
+ return result;
13807
13849
  }
13808
- // node_modules/drizzle-orm/pg-core/columns/smallint.js
13809
- var PgSmallIntBuilder = class extends PgIntColumnBuilder {
13810
- static [entityKind] = "PgSmallIntBuilder";
13811
- constructor(name2) {
13812
- super(name2, "number int16", "PgSmallInt");
13850
+ function makePgArray(array) {
13851
+ return `{${array.map((item) => {
13852
+ if (Array.isArray(item))
13853
+ return makePgArray(item);
13854
+ if (typeof item === "string")
13855
+ return `"${item.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
13856
+ return `${item}`;
13857
+ }).join(",")}}`;
13858
+ }
13859
+
13860
+ // node_modules/drizzle-orm/pg-core/columns/postgis_extension/utils.js
13861
+ function hexToBytes(hex) {
13862
+ const bytes = [];
13863
+ for (let c = 0;c < hex.length; c += 2)
13864
+ bytes.push(Number.parseInt(hex.slice(c, c + 2), 16));
13865
+ return new Uint8Array(bytes);
13866
+ }
13867
+ function bytesToFloat64(bytes, offset) {
13868
+ const buffer = /* @__PURE__ */ new ArrayBuffer(8);
13869
+ const view = new DataView(buffer);
13870
+ for (let i = 0;i < 8; i++)
13871
+ view.setUint8(i, bytes[offset + i]);
13872
+ return view.getFloat64(0, true);
13873
+ }
13874
+ function parseEWKB(hex) {
13875
+ const bytes = hexToBytes(hex);
13876
+ let offset = 0;
13877
+ const byteOrder = bytes[offset];
13878
+ offset += 1;
13879
+ const view = new DataView(bytes.buffer);
13880
+ const geomType = view.getUint32(offset, byteOrder === 1);
13881
+ offset += 4;
13882
+ let srid;
13883
+ if (geomType & 536870912) {
13884
+ srid = view.getUint32(offset, byteOrder === 1);
13885
+ offset += 4;
13813
13886
  }
13814
- build(table) {
13815
- return new PgSmallInt(table, this.config);
13887
+ if ((geomType & 65535) === 1) {
13888
+ const x = bytesToFloat64(bytes, offset);
13889
+ offset += 8;
13890
+ const y = bytesToFloat64(bytes, offset);
13891
+ offset += 8;
13892
+ return {
13893
+ srid,
13894
+ point: [x, y]
13895
+ };
13816
13896
  }
13897
+ throw new Error("Unsupported geometry type");
13898
+ }
13899
+
13900
+ // node_modules/drizzle-orm/codecs.js
13901
+ var noopCodecs = {};
13902
+ var arrayToItemTypeCodecNameMap = {
13903
+ cast: "cast",
13904
+ castArray: "cast",
13905
+ castInJson: "castInJson",
13906
+ castArrayInJson: "castInJson",
13907
+ castParam: "castParam",
13908
+ castArrayParam: "castParam",
13909
+ normalize: "normalize",
13910
+ normalizeArray: "normalize",
13911
+ normalizeInJson: "normalizeInJson",
13912
+ normalizeArrayInJson: "normalizeInJson",
13913
+ normalizeParam: "normalizeParam",
13914
+ normalizeParamArray: "normalizeParam"
13817
13915
  };
13818
- var PgSmallInt = class extends PgColumn {
13819
- static [entityKind] = "PgSmallInt";
13820
- codec = "smallint";
13821
- getSQLType() {
13822
- return "smallint";
13823
- }
13916
+ var itemToArrayTypeCodecNameMap = {
13917
+ cast: "castArray",
13918
+ castArray: "castArray",
13919
+ castInJson: "castArrayInJson",
13920
+ castArrayInJson: "castArrayInJson",
13921
+ castParam: "castArrayParam",
13922
+ castArrayParam: "castArrayParam",
13923
+ normalize: "normalizeArray",
13924
+ normalizeArray: "normalizeArray",
13925
+ normalizeInJson: "normalizeArrayInJson",
13926
+ normalizeArrayInJson: "normalizeArrayInJson",
13927
+ normalizeParam: "normalizeParamArray",
13928
+ normalizeParamArray: "normalizeParamArray"
13824
13929
  };
13825
- function smallint(name2) {
13826
- return new PgSmallIntBuilder(name2 ?? "");
13827
- }
13828
- // node_modules/drizzle-orm/pg-core/columns/text.js
13829
- var PgTextBuilder = class extends PgColumnBuilder {
13830
- static [entityKind] = "PgTextBuilder";
13831
- constructor(name2, config) {
13832
- super(name2, config.enum?.length ? "string enum" : "string", "PgText");
13833
- this.config.enumValues = config.enum;
13834
- }
13835
- build(table) {
13836
- return new PgText(table, this.config, this.config.enumValues);
13930
+ var CodecsCollection = class {
13931
+ static [entityKind] = "CodecsCollection";
13932
+ constructor(resolveTypes, codecs = noopCodecs) {
13933
+ this.resolveTypes = resolveTypes;
13934
+ this.codecs = codecs;
13837
13935
  }
13838
- };
13839
- var PgText = class extends PgColumn {
13840
- static [entityKind] = "PgText";
13841
- enumValues;
13842
- codec = "text";
13843
- constructor(table, config, enumValues) {
13844
- super(table, config);
13845
- this.enumValues = enumValues;
13936
+ get(column, type, override) {
13937
+ const sqlType = override ?? column.codec;
13938
+ if (!sqlType)
13939
+ return;
13940
+ const codecType = column.dimensions ? itemToArrayTypeCodecNameMap[type] : arrayToItemTypeCodecNameMap[type];
13941
+ return this.codecs[sqlType]?.[codecType];
13846
13942
  }
13847
- getSQLType() {
13848
- return "text";
13849
- }
13850
- };
13851
- function text(a, b = {}) {
13852
- const { name: name2, config } = getColumnNameAndConfig2(a, b);
13853
- return new PgTextBuilder(name2, config);
13854
- }
13855
- // node_modules/drizzle-orm/pg-core/columns/date.common.js
13856
- var PgDateColumnBuilder = class extends PgColumnBuilder {
13857
- static [entityKind] = "PgDateColumnBaseBuilder";
13858
- defaultNow() {
13859
- return this.default(sql`now()`);
13860
- }
13861
- };
13862
-
13863
- // node_modules/drizzle-orm/pg-core/columns/timestamp.js
13864
- var PgTimestampBuilder = class extends PgDateColumnBuilder {
13865
- static [entityKind] = "PgTimestampBuilder";
13866
- constructor(name2, withTimezone, precision) {
13867
- super(name2, "object date", "PgTimestamp");
13868
- this.config.withTimezone = withTimezone;
13869
- this.config.precision = precision;
13870
- }
13871
- build(table) {
13872
- return new PgTimestamp(table, this.config);
13873
- }
13874
- };
13875
- var PgTimestamp = class extends PgColumn {
13876
- static [entityKind] = "PgTimestamp";
13877
- codec;
13878
- withTimezone;
13879
- precision;
13880
- constructor(table, config) {
13881
- super(table, config);
13882
- this.withTimezone = config.withTimezone;
13883
- this.precision = config.precision;
13884
- this.codec = this.withTimezone ? "timestamptz" : "timestamp";
13885
- }
13886
- getSQLType() {
13887
- return `timestamp${this.precision === undefined ? "" : ` (${this.precision})`}${this.withTimezone ? " with time zone" : ""}`;
13888
- }
13889
- mapToDriverValue = (value) => {
13890
- if (typeof value === "string")
13891
- return value;
13892
- return value.toISOString();
13893
- };
13894
- };
13895
- var PgTimestampStringBuilder = class extends PgDateColumnBuilder {
13896
- static [entityKind] = "PgTimestampStringBuilder";
13897
- constructor(name2, withTimezone, precision) {
13898
- super(name2, "string timestamp", "PgTimestampString");
13899
- this.config.withTimezone = withTimezone;
13900
- this.config.precision = precision;
13901
- }
13902
- build(table) {
13903
- return new PgTimestampString(table, this.config);
13904
- }
13905
- };
13906
- var PgTimestampString = class extends PgColumn {
13907
- static [entityKind] = "PgTimestampString";
13908
- codec;
13909
- withTimezone;
13910
- precision;
13911
- constructor(table, config) {
13912
- super(table, config);
13913
- this.withTimezone = config.withTimezone;
13914
- this.precision = config.precision;
13915
- this.codec = this.withTimezone ? "timestamptz:string" : "timestamp:string";
13916
- }
13917
- getSQLType() {
13918
- return `timestamp${this.precision === undefined ? "" : `(${this.precision})`}${this.withTimezone ? " with time zone" : ""}`;
13919
- }
13920
- mapToDriverValue = (value) => {
13921
- if (typeof value === "string")
13922
- return value;
13923
- return value.toISOString();
13924
- };
13925
- };
13926
- function timestamp(a, b = {}) {
13927
- const { name: name2, config } = getColumnNameAndConfig2(a, b);
13928
- if (config?.mode === "string")
13929
- return new PgTimestampStringBuilder(name2, config.withTimezone ?? false, config.precision);
13930
- return new PgTimestampBuilder(name2, config?.withTimezone ?? false, config?.precision);
13931
- }
13932
- // node_modules/drizzle-orm/pg-core/columns/varchar.js
13933
- var PgVarcharBuilder = class extends PgColumnBuilder {
13934
- static [entityKind] = "PgVarcharBuilder";
13935
- constructor(name2, config) {
13936
- super(name2, config.enum?.length ? "string enum" : "string", "PgVarchar");
13937
- this.config.length = config.length;
13938
- this.config.enumValues = config.enum;
13939
- }
13940
- build(table) {
13941
- return new PgVarchar(table, this.config);
13942
- }
13943
- };
13944
- var PgVarchar = class extends PgColumn {
13945
- static [entityKind] = "PgVarchar";
13946
- codec = "varchar";
13947
- enumValues;
13948
- constructor(table, config) {
13949
- super(table, config);
13950
- this.enumValues = config.enumValues;
13951
- }
13952
- getSQLType() {
13953
- return this.length === undefined ? `varchar` : `varchar(${this.length})`;
13954
- }
13955
- };
13956
- function varchar(a, b = {}) {
13957
- const { name: name2, config } = getColumnNameAndConfig2(a, b);
13958
- return new PgVarcharBuilder(name2, config);
13959
- }
13960
- // node_modules/drizzle-orm/pg-core/columns/bigserial.js
13961
- var PgBigSerial53Builder = class extends PgColumnBuilder {
13962
- static [entityKind] = "PgBigSerial53Builder";
13963
- constructor(name2) {
13964
- super(name2, "number int53", "PgBigSerial53");
13965
- this.config.hasDefault = true;
13966
- this.config.notNull = true;
13967
- }
13968
- build(table) {
13969
- return new PgBigSerial53(table, this.config);
13970
- }
13971
- };
13972
- var PgBigSerial53 = class extends PgColumn {
13973
- static [entityKind] = "PgBigSerial53";
13974
- codec = "bigserial:number";
13975
- getSQLType() {
13976
- return "bigserial";
13977
- }
13978
- };
13979
- var PgBigSerial64Builder = class extends PgColumnBuilder {
13980
- static [entityKind] = "PgBigSerial64Builder";
13981
- constructor(name2) {
13982
- super(name2, "bigint int64", "PgBigSerial64");
13983
- this.config.hasDefault = true;
13984
- this.config.notNull = true;
13985
- }
13986
- build(table) {
13987
- return new PgBigSerial64(table, this.config);
13988
- }
13989
- };
13990
- var PgBigSerial64 = class extends PgColumn {
13991
- static [entityKind] = "PgBigSerial64";
13992
- codec = "bigserial";
13993
- getSQLType() {
13994
- return "bigserial";
13995
- }
13996
- };
13997
- function bigserial(a, b) {
13998
- const { name: name2, config } = getColumnNameAndConfig2(a, b);
13999
- if (config.mode === "number")
14000
- return new PgBigSerial53Builder(name2);
14001
- return new PgBigSerial64Builder(name2);
14002
- }
14003
-
14004
- // node_modules/drizzle-orm/pg-core/columns/char.js
14005
- var PgCharBuilder = class extends PgColumnBuilder {
14006
- static [entityKind] = "PgCharBuilder";
14007
- constructor(name2, config) {
14008
- super(name2, config.enum?.length ? "string enum" : "string", "PgChar");
14009
- this.config.length = config.length ?? 1;
14010
- this.config.setLength = config.length !== undefined;
14011
- this.config.enumValues = config.enum;
14012
- }
14013
- build(table) {
14014
- return new PgChar(table, this.config);
14015
- }
14016
- };
14017
- var PgChar = class extends PgColumn {
14018
- static [entityKind] = "PgChar";
14019
- codec = "char";
14020
- enumValues;
14021
- setLength;
14022
- constructor(table, config) {
14023
- super(table, config);
14024
- this.enumValues = config.enumValues;
14025
- this.setLength = config.setLength;
14026
- }
14027
- getSQLType() {
14028
- return this.setLength ? `char(${this.length})` : `char`;
14029
- }
14030
- };
14031
- function char(a, b = {}) {
14032
- const { name: name2, config } = getColumnNameAndConfig2(a, b);
14033
- return new PgCharBuilder(name2, config);
14034
- }
14035
-
14036
- // node_modules/drizzle-orm/pg-core/columns/cidr.js
14037
- var PgCidrBuilder = class extends PgColumnBuilder {
14038
- static [entityKind] = "PgCidrBuilder";
14039
- constructor(name2) {
14040
- super(name2, "string cidr", "PgCidr");
14041
- }
14042
- build(table) {
14043
- return new PgCidr(table, this.config);
14044
- }
14045
- };
14046
- var PgCidr = class extends PgColumn {
14047
- static [entityKind] = "PgCidr";
14048
- codec = "cidr";
14049
- getSQLType() {
14050
- return "cidr";
14051
- }
14052
- };
14053
- function cidr(name2) {
14054
- return new PgCidrBuilder(name2 ?? "");
14055
- }
14056
-
14057
- // node_modules/drizzle-orm/pg-core/array.js
14058
- function parsePgArrayValue(arrayString, startFrom, inQuotes) {
14059
- for (let i = startFrom;i < arrayString.length; i++) {
14060
- const char2 = arrayString[i];
14061
- if (char2 === "\\") {
14062
- i++;
14063
- continue;
14064
- }
14065
- if (char2 === '"')
14066
- return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i + 1];
14067
- if (inQuotes)
14068
- continue;
14069
- if (char2 === "," || char2 === "}")
14070
- return [arrayString.slice(startFrom, i).replace(/\\/g, ""), i];
14071
- }
14072
- return [arrayString.slice(startFrom).replace(/\\/g, ""), arrayString.length];
14073
- }
14074
- function parsePgNestedArray(arrayString, startFrom = 0) {
14075
- const result = [];
14076
- let i = startFrom;
14077
- let lastCharIsComma = false;
14078
- while (i < arrayString.length) {
14079
- const char2 = arrayString[i];
14080
- if (char2 === ",") {
14081
- if (lastCharIsComma || i === startFrom)
14082
- result.push("");
14083
- lastCharIsComma = true;
14084
- i++;
14085
- continue;
14086
- }
14087
- lastCharIsComma = false;
14088
- if (char2 === "\\") {
14089
- i += 2;
14090
- continue;
14091
- }
14092
- if (char2 === '"') {
14093
- const [value2, startFrom2] = parsePgArrayValue(arrayString, i + 1, true);
14094
- result.push(value2);
14095
- i = startFrom2;
14096
- continue;
14097
- }
14098
- if (char2 === "}")
14099
- return [result, i + 1];
14100
- if (char2 === "{") {
14101
- const [value2, startFrom2] = parsePgNestedArray(arrayString, i + 1);
14102
- result.push(value2);
14103
- i = startFrom2;
14104
- continue;
14105
- }
14106
- const [value, newStartFrom] = parsePgArrayValue(arrayString, i, false);
14107
- result.push(value);
14108
- i = newStartFrom;
14109
- }
14110
- return [result, i];
14111
- }
14112
- function parsePgArray(arrayString) {
14113
- const [result] = parsePgNestedArray(arrayString, 1);
14114
- return result;
14115
- }
14116
- function makePgArray(array) {
14117
- return `{${array.map((item) => {
14118
- if (Array.isArray(item))
14119
- return makePgArray(item);
14120
- if (typeof item === "string")
14121
- return `"${item.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
14122
- return `${item}`;
14123
- }).join(",")}}`;
14124
- }
14125
-
14126
- // node_modules/drizzle-orm/pg-core/columns/postgis_extension/utils.js
14127
- function hexToBytes(hex) {
14128
- const bytes = [];
14129
- for (let c = 0;c < hex.length; c += 2)
14130
- bytes.push(Number.parseInt(hex.slice(c, c + 2), 16));
14131
- return new Uint8Array(bytes);
14132
- }
14133
- function bytesToFloat64(bytes, offset) {
14134
- const buffer = /* @__PURE__ */ new ArrayBuffer(8);
14135
- const view = new DataView(buffer);
14136
- for (let i = 0;i < 8; i++)
14137
- view.setUint8(i, bytes[offset + i]);
14138
- return view.getFloat64(0, true);
14139
- }
14140
- function parseEWKB(hex) {
14141
- const bytes = hexToBytes(hex);
14142
- let offset = 0;
14143
- const byteOrder = bytes[offset];
14144
- offset += 1;
14145
- const view = new DataView(bytes.buffer);
14146
- const geomType = view.getUint32(offset, byteOrder === 1);
14147
- offset += 4;
14148
- let srid;
14149
- if (geomType & 536870912) {
14150
- srid = view.getUint32(offset, byteOrder === 1);
14151
- offset += 4;
14152
- }
14153
- if ((geomType & 65535) === 1) {
14154
- const x = bytesToFloat64(bytes, offset);
14155
- offset += 8;
14156
- const y = bytesToFloat64(bytes, offset);
14157
- offset += 8;
14158
- return {
14159
- srid,
14160
- point: [x, y]
14161
- };
14162
- }
14163
- throw new Error("Unsupported geometry type");
14164
- }
14165
-
14166
- // node_modules/drizzle-orm/codecs.js
14167
- var noopCodecs = {};
14168
- var arrayToItemTypeCodecNameMap = {
14169
- cast: "cast",
14170
- castArray: "cast",
14171
- castInJson: "castInJson",
14172
- castArrayInJson: "castInJson",
14173
- castParam: "castParam",
14174
- castArrayParam: "castParam",
14175
- normalize: "normalize",
14176
- normalizeArray: "normalize",
14177
- normalizeInJson: "normalizeInJson",
14178
- normalizeArrayInJson: "normalizeInJson",
14179
- normalizeParam: "normalizeParam",
14180
- normalizeParamArray: "normalizeParam"
14181
- };
14182
- var itemToArrayTypeCodecNameMap = {
14183
- cast: "castArray",
14184
- castArray: "castArray",
14185
- castInJson: "castArrayInJson",
14186
- castArrayInJson: "castArrayInJson",
14187
- castParam: "castArrayParam",
14188
- castArrayParam: "castArrayParam",
14189
- normalize: "normalizeArray",
14190
- normalizeArray: "normalizeArray",
14191
- normalizeInJson: "normalizeArrayInJson",
14192
- normalizeArrayInJson: "normalizeArrayInJson",
14193
- normalizeParam: "normalizeParamArray",
14194
- normalizeParamArray: "normalizeParamArray"
14195
- };
14196
- var CodecsCollection = class {
14197
- static [entityKind] = "CodecsCollection";
14198
- constructor(resolveTypes, codecs = noopCodecs) {
14199
- this.resolveTypes = resolveTypes;
14200
- this.codecs = codecs;
14201
- }
14202
- get(column, type) {
14203
- const sqlType = column.codec;
14204
- if (!sqlType)
14205
- return;
14206
- const codecType = column.dimensions ? itemToArrayTypeCodecNameMap[type] : arrayToItemTypeCodecNameMap[type];
14207
- return this.codecs[sqlType]?.[codecType];
14208
- }
14209
- apply(column, type, value) {
14210
- const sqlType = column.codec;
14211
- if (!sqlType)
14212
- return value;
14213
- const codecType = column.dimensions ? itemToArrayTypeCodecNameMap[type] : arrayToItemTypeCodecNameMap[type];
14214
- const codec = this.codecs[sqlType]?.[codecType];
14215
- if (!codec)
14216
- return value;
14217
- if (codecType === "castParam" || codecType === "castArrayParam")
14218
- return codec(value, column, column.dimensions);
14219
- return codec(value, column.dimensions);
13943
+ apply(column, type, value, override) {
13944
+ const sqlType = override ?? column.codec;
13945
+ if (!sqlType)
13946
+ return value;
13947
+ const codecType = column.dimensions ? itemToArrayTypeCodecNameMap[type] : arrayToItemTypeCodecNameMap[type];
13948
+ const codec = this.codecs[sqlType]?.[codecType];
13949
+ if (!codec)
13950
+ return value;
13951
+ if (codecType === "castParam" || codecType === "castArrayParam")
13952
+ return codec(value, column, column.dimensions);
13953
+ return codec(value, column.dimensions);
14220
13954
  }
14221
13955
  };
14222
13956
  function refineCodecs(source, extension = {}) {
@@ -14236,34 +13970,661 @@ function refineCodecs(source, extension = {}) {
14236
13970
  for (const ik of innerKeys)
14237
13971
  result[k][ik] = ik in extension[k] ? extension[k][ik] : source[k]?.[ik];
14238
13972
  }
14239
- return result;
14240
- }
14241
-
14242
- // node_modules/drizzle-orm/pg-core/codecs.js
14243
- var PG_ALIAS_TO_TYPE_MAP = {
14244
- int2: "smallint",
14245
- integer: "int",
14246
- int4: "int",
14247
- int8: "bigint",
14248
- decimal: "numeric",
14249
- real: "float4",
14250
- double: "float8",
14251
- "double precision": "float8",
14252
- serial2: "smallserial",
14253
- serial4: "serial",
14254
- serial8: "bigserial",
14255
- character: "char",
14256
- "character varying": "varchar",
14257
- "time with time zone": "timetz",
14258
- "time without time zone": "time",
14259
- "timestamp with time zone": "timestamptz",
14260
- "timestamp without time zone": "timestamp",
14261
- boolean: "bool",
14262
- "bit varying": "varbit"
13973
+ return result;
13974
+ }
13975
+
13976
+ // node_modules/drizzle-orm/pg-core/codecs.js
13977
+ var PG_ALIAS_TO_TYPE_MAP = {
13978
+ int2: "smallint",
13979
+ integer: "int",
13980
+ int4: "int",
13981
+ int8: "bigint",
13982
+ decimal: "numeric",
13983
+ real: "float4",
13984
+ double: "float8",
13985
+ "double precision": "float8",
13986
+ serial2: "smallserial",
13987
+ serial4: "serial",
13988
+ serial8: "bigserial",
13989
+ character: "char",
13990
+ "character varying": "varchar",
13991
+ "time with time zone": "timetz",
13992
+ "time without time zone": "time",
13993
+ "timestamp with time zone": "timestamptz",
13994
+ "timestamp without time zone": "timestamp",
13995
+ boolean: "bool",
13996
+ "bit varying": "varbit"
13997
+ };
13998
+ function resolvePgTypeAlias(type) {
13999
+ return PG_ALIAS_TO_TYPE_MAP[type] ?? type;
14000
+ }
14001
+ var unionsTypeTable = {
14002
+ smallint: {
14003
+ smallint: "smallint",
14004
+ int: "int",
14005
+ bigint: "bigint:number",
14006
+ "bigint:number": "bigint:number",
14007
+ "bigint:string": "bigint:number",
14008
+ numeric: "numeric:number",
14009
+ "numeric:number": "numeric:number",
14010
+ "numeric:bigint": "numeric:number",
14011
+ float4: "float4",
14012
+ float8: "float8",
14013
+ smallserial: "smallint",
14014
+ serial: "int",
14015
+ bigserial: "bigint:number",
14016
+ "bigserial:number": "bigint:number",
14017
+ oid: "oid",
14018
+ regproc: "regproc",
14019
+ regprocedure: "regprocedure",
14020
+ regoper: "regoper",
14021
+ regoperator: "regoperator",
14022
+ regclass: "regclass",
14023
+ regtype: "regtype",
14024
+ regrole: "regrole",
14025
+ regnamespace: "regnamespace",
14026
+ regconfig: "regconfig",
14027
+ regdictionary: "regdictionary"
14028
+ },
14029
+ int: {
14030
+ smallint: "int",
14031
+ int: "int",
14032
+ bigint: "bigint:number",
14033
+ "bigint:number": "bigint:number",
14034
+ "bigint:string": "bigint:number",
14035
+ numeric: "numeric:number",
14036
+ "numeric:number": "numeric:number",
14037
+ "numeric:bigint": "numeric:number",
14038
+ float4: "float4",
14039
+ float8: "float8",
14040
+ smallserial: "int",
14041
+ serial: "int",
14042
+ bigserial: "bigint:number",
14043
+ "bigserial:number": "bigint:number",
14044
+ oid: "oid",
14045
+ regproc: "regproc",
14046
+ regprocedure: "regprocedure",
14047
+ regoper: "regoper",
14048
+ regoperator: "regoperator",
14049
+ regclass: "regclass",
14050
+ regtype: "regtype",
14051
+ regrole: "regrole",
14052
+ regnamespace: "regnamespace",
14053
+ regconfig: "regconfig",
14054
+ regdictionary: "regdictionary"
14055
+ },
14056
+ bigint: {
14057
+ smallint: "bigint",
14058
+ int: "bigint",
14059
+ bigint: "bigint",
14060
+ "bigint:number": "bigint",
14061
+ "bigint:string": "bigint",
14062
+ numeric: "numeric:bigint",
14063
+ "numeric:number": "numeric:bigint",
14064
+ "numeric:bigint": "numeric:bigint",
14065
+ float4: "float4",
14066
+ float8: "float8",
14067
+ smallserial: "bigint",
14068
+ serial: "bigint",
14069
+ bigserial: "bigint",
14070
+ "bigserial:number": "bigint",
14071
+ oid: "oid",
14072
+ regproc: "regproc",
14073
+ regprocedure: "regprocedure",
14074
+ regoper: "regoper",
14075
+ regoperator: "regoperator",
14076
+ regclass: "regclass",
14077
+ regtype: "regtype",
14078
+ regrole: "regrole",
14079
+ regnamespace: "regnamespace",
14080
+ regconfig: "regconfig",
14081
+ regdictionary: "regdictionary"
14082
+ },
14083
+ "bigint:number": {
14084
+ smallint: "bigint:number",
14085
+ int: "bigint:number",
14086
+ bigint: "bigint:number",
14087
+ "bigint:number": "bigint:number",
14088
+ "bigint:string": "bigint:number",
14089
+ numeric: "numeric:number",
14090
+ "numeric:number": "numeric:number",
14091
+ "numeric:bigint": "numeric:number",
14092
+ float4: "float4",
14093
+ float8: "float8",
14094
+ smallserial: "bigint:number",
14095
+ serial: "bigint:number",
14096
+ bigserial: "bigint:number",
14097
+ "bigserial:number": "bigint:number",
14098
+ oid: "oid",
14099
+ regproc: "regproc",
14100
+ regprocedure: "regprocedure",
14101
+ regoper: "regoper",
14102
+ regoperator: "regoperator",
14103
+ regclass: "regclass",
14104
+ regtype: "regtype",
14105
+ regrole: "regrole",
14106
+ regnamespace: "regnamespace",
14107
+ regconfig: "regconfig",
14108
+ regdictionary: "regdictionary"
14109
+ },
14110
+ "bigint:string": {
14111
+ smallint: "bigint:string",
14112
+ int: "bigint:string",
14113
+ bigint: "bigint:string",
14114
+ "bigint:number": "bigint:string",
14115
+ "bigint:string": "bigint:string",
14116
+ numeric: "numeric",
14117
+ "numeric:number": "numeric",
14118
+ "numeric:bigint": "numeric",
14119
+ float4: "float4",
14120
+ float8: "float8",
14121
+ smallserial: "bigint:string",
14122
+ serial: "bigint:string",
14123
+ bigserial: "bigint:string",
14124
+ "bigserial:number": "bigint:string",
14125
+ oid: "oid",
14126
+ regproc: "regproc",
14127
+ regprocedure: "regprocedure",
14128
+ regoper: "regoper",
14129
+ regoperator: "regoperator",
14130
+ regclass: "regclass",
14131
+ regtype: "regtype",
14132
+ regrole: "regrole",
14133
+ regnamespace: "regnamespace",
14134
+ regconfig: "regconfig",
14135
+ regdictionary: "regdictionary"
14136
+ },
14137
+ numeric: {
14138
+ smallint: "numeric",
14139
+ int: "numeric",
14140
+ bigint: "numeric",
14141
+ "bigint:number": "numeric",
14142
+ "bigint:string": "numeric",
14143
+ numeric: "numeric",
14144
+ "numeric:number": "numeric",
14145
+ "numeric:bigint": "numeric",
14146
+ float4: "float4",
14147
+ float8: "float8",
14148
+ smallserial: "numeric",
14149
+ serial: "numeric",
14150
+ bigserial: "numeric",
14151
+ "bigserial:number": "numeric"
14152
+ },
14153
+ "numeric:number": {
14154
+ smallint: "numeric:number",
14155
+ int: "numeric:number",
14156
+ bigint: "numeric:number",
14157
+ "bigint:number": "numeric:number",
14158
+ "bigint:string": "numeric:number",
14159
+ numeric: "numeric:number",
14160
+ "numeric:number": "numeric:number",
14161
+ "numeric:bigint": "numeric:number",
14162
+ float4: "float4",
14163
+ float8: "float8",
14164
+ smallserial: "numeric:number",
14165
+ serial: "numeric:number",
14166
+ bigserial: "numeric:number",
14167
+ "bigserial:number": "numeric:number"
14168
+ },
14169
+ "numeric:bigint": {
14170
+ smallint: "numeric:bigint",
14171
+ int: "numeric:bigint",
14172
+ bigint: "numeric:bigint",
14173
+ "bigint:number": "numeric:bigint",
14174
+ "bigint:string": "numeric:bigint",
14175
+ numeric: "numeric:bigint",
14176
+ "numeric:number": "numeric:bigint",
14177
+ "numeric:bigint": "numeric:bigint",
14178
+ float4: "float4",
14179
+ float8: "float8",
14180
+ smallserial: "numeric:bigint",
14181
+ serial: "numeric:bigint",
14182
+ bigserial: "numeric:bigint",
14183
+ "bigserial:number": "numeric:bigint"
14184
+ },
14185
+ float4: {
14186
+ smallint: "float4",
14187
+ int: "float4",
14188
+ bigint: "float4",
14189
+ "bigint:number": "float4",
14190
+ "bigint:string": "float4",
14191
+ numeric: "float4",
14192
+ "numeric:number": "float4",
14193
+ "numeric:bigint": "float4",
14194
+ float4: "float4",
14195
+ float8: "float8",
14196
+ smallserial: "float4",
14197
+ serial: "float4",
14198
+ bigserial: "float4",
14199
+ "bigserial:number": "float4"
14200
+ },
14201
+ float8: {
14202
+ smallint: "float8",
14203
+ int: "float8",
14204
+ bigint: "float8",
14205
+ "bigint:number": "float8",
14206
+ "bigint:string": "float8",
14207
+ numeric: "float8",
14208
+ "numeric:number": "float8",
14209
+ "numeric:bigint": "float8",
14210
+ float4: "float8",
14211
+ float8: "float8",
14212
+ smallserial: "float8",
14213
+ serial: "float8",
14214
+ bigserial: "float8",
14215
+ "bigserial:number": "float8"
14216
+ },
14217
+ money: { money: "money" },
14218
+ smallserial: {
14219
+ smallint: "smallint",
14220
+ int: "int",
14221
+ bigint: "bigint:number",
14222
+ "bigint:number": "bigint:number",
14223
+ "bigint:string": "bigint:number",
14224
+ numeric: "numeric:number",
14225
+ "numeric:number": "numeric:number",
14226
+ "numeric:bigint": "numeric:number",
14227
+ float4: "float4",
14228
+ float8: "float8",
14229
+ smallserial: "smallint",
14230
+ serial: "int",
14231
+ bigserial: "bigint:number",
14232
+ "bigserial:number": "bigint:number",
14233
+ oid: "oid",
14234
+ regproc: "regproc",
14235
+ regprocedure: "regprocedure",
14236
+ regoper: "regoper",
14237
+ regoperator: "regoperator",
14238
+ regclass: "regclass",
14239
+ regtype: "regtype",
14240
+ regrole: "regrole",
14241
+ regnamespace: "regnamespace",
14242
+ regconfig: "regconfig",
14243
+ regdictionary: "regdictionary"
14244
+ },
14245
+ serial: {
14246
+ smallint: "int",
14247
+ int: "int",
14248
+ bigint: "bigint:number",
14249
+ "bigint:number": "bigint:number",
14250
+ "bigint:string": "bigint:number",
14251
+ numeric: "numeric:number",
14252
+ "numeric:number": "numeric:number",
14253
+ "numeric:bigint": "numeric:number",
14254
+ float4: "float4",
14255
+ float8: "float8",
14256
+ smallserial: "int",
14257
+ serial: "int",
14258
+ bigserial: "bigint:number",
14259
+ "bigserial:number": "bigint:number",
14260
+ oid: "oid",
14261
+ regproc: "regproc",
14262
+ regprocedure: "regprocedure",
14263
+ regoper: "regoper",
14264
+ regoperator: "regoperator",
14265
+ regclass: "regclass",
14266
+ regtype: "regtype",
14267
+ regrole: "regrole",
14268
+ regnamespace: "regnamespace",
14269
+ regconfig: "regconfig",
14270
+ regdictionary: "regdictionary"
14271
+ },
14272
+ bigserial: {
14273
+ smallint: "bigint",
14274
+ int: "bigint",
14275
+ bigint: "bigint",
14276
+ "bigint:number": "bigint",
14277
+ "bigint:string": "bigint",
14278
+ numeric: "numeric:bigint",
14279
+ "numeric:number": "numeric:bigint",
14280
+ "numeric:bigint": "numeric:bigint",
14281
+ float4: "float4",
14282
+ float8: "float8",
14283
+ smallserial: "bigint",
14284
+ serial: "bigint",
14285
+ bigserial: "bigint",
14286
+ "bigserial:number": "bigint",
14287
+ oid: "oid",
14288
+ regproc: "regproc",
14289
+ regprocedure: "regprocedure",
14290
+ regoper: "regoper",
14291
+ regoperator: "regoperator",
14292
+ regclass: "regclass",
14293
+ regtype: "regtype",
14294
+ regrole: "regrole",
14295
+ regnamespace: "regnamespace",
14296
+ regconfig: "regconfig",
14297
+ regdictionary: "regdictionary"
14298
+ },
14299
+ "bigserial:number": {
14300
+ smallint: "bigint:number",
14301
+ int: "bigint:number",
14302
+ bigint: "bigint:number",
14303
+ "bigint:number": "bigint:number",
14304
+ "bigint:string": "bigint:number",
14305
+ numeric: "numeric:number",
14306
+ "numeric:number": "numeric:number",
14307
+ "numeric:bigint": "numeric:number",
14308
+ float4: "float4",
14309
+ float8: "float8",
14310
+ smallserial: "bigint:number",
14311
+ serial: "bigint:number",
14312
+ bigserial: "bigint:number",
14313
+ "bigserial:number": "bigint:number",
14314
+ oid: "oid",
14315
+ regproc: "regproc",
14316
+ regprocedure: "regprocedure",
14317
+ regoper: "regoper",
14318
+ regoperator: "regoperator",
14319
+ regclass: "regclass",
14320
+ regtype: "regtype",
14321
+ regrole: "regrole",
14322
+ regnamespace: "regnamespace",
14323
+ regconfig: "regconfig",
14324
+ regdictionary: "regdictionary"
14325
+ },
14326
+ char: {
14327
+ char: "char",
14328
+ varchar: "char",
14329
+ text: "char"
14330
+ },
14331
+ varchar: {
14332
+ char: "varchar",
14333
+ varchar: "varchar",
14334
+ text: "varchar"
14335
+ },
14336
+ text: {
14337
+ char: "text",
14338
+ varchar: "text",
14339
+ text: "text"
14340
+ },
14341
+ bytea: { bytea: "bytea" },
14342
+ date: {
14343
+ date: "date",
14344
+ "date:string": "date",
14345
+ timestamp: "timestamp",
14346
+ "timestamp:string": "timestamp",
14347
+ timestamptz: "timestamptz",
14348
+ "timestamptz:string": "timestamptz"
14349
+ },
14350
+ "date:string": {
14351
+ date: "date:string",
14352
+ "date:string": "date:string",
14353
+ timestamp: "timestamp:string",
14354
+ "timestamp:string": "timestamp:string",
14355
+ timestamptz: "timestamptz:string",
14356
+ "timestamptz:string": "timestamptz:string"
14357
+ },
14358
+ time: {
14359
+ time: "time",
14360
+ timetz: "timetz"
14361
+ },
14362
+ timetz: {
14363
+ time: "timetz",
14364
+ timetz: "timetz"
14365
+ },
14366
+ timestamp: {
14367
+ date: "timestamp",
14368
+ "date:string": "timestamp",
14369
+ timestamp: "timestamp",
14370
+ "timestamp:string": "timestamp",
14371
+ timestamptz: "timestamptz",
14372
+ "timestamptz:string": "timestamptz"
14373
+ },
14374
+ "timestamp:string": {
14375
+ date: "timestamp:string",
14376
+ "date:string": "timestamp:string",
14377
+ timestamp: "timestamp:string",
14378
+ "timestamp:string": "timestamp:string",
14379
+ timestamptz: "timestamptz:string",
14380
+ "timestamptz:string": "timestamptz:string"
14381
+ },
14382
+ timestamptz: {
14383
+ date: "timestamptz",
14384
+ "date:string": "timestamptz",
14385
+ timestamp: "timestamptz",
14386
+ "timestamp:string": "timestamptz",
14387
+ timestamptz: "timestamptz",
14388
+ "timestamptz:string": "timestamptz"
14389
+ },
14390
+ "timestamptz:string": {
14391
+ date: "timestamptz:string",
14392
+ "date:string": "timestamptz:string",
14393
+ timestamp: "timestamptz:string",
14394
+ "timestamp:string": "timestamptz:string",
14395
+ timestamptz: "timestamptz:string",
14396
+ "timestamptz:string": "timestamptz:string"
14397
+ },
14398
+ interval: {
14399
+ interval: "interval",
14400
+ "interval:tuple": "interval"
14401
+ },
14402
+ "interval:tuple": {
14403
+ interval: "interval:tuple",
14404
+ "interval:tuple": "interval:tuple"
14405
+ },
14406
+ bool: { bool: "bool" },
14407
+ enum: { enum: "enum" },
14408
+ point: {
14409
+ point: "point",
14410
+ "point:tuple": "point"
14411
+ },
14412
+ "point:tuple": {
14413
+ point: "point:tuple",
14414
+ "point:tuple": "point:tuple"
14415
+ },
14416
+ line: {
14417
+ line: "line",
14418
+ "line:tuple": "line"
14419
+ },
14420
+ "line:tuple": {
14421
+ line: "line:tuple",
14422
+ "line:tuple": "line:tuple"
14423
+ },
14424
+ lseg: { lseg: "lseg" },
14425
+ box: { box: "box" },
14426
+ path: { path: "path" },
14427
+ polygon: { polygon: "polygon" },
14428
+ circle: { circle: "circle" },
14429
+ cidr: {
14430
+ cidr: "cidr",
14431
+ inet: "inet"
14432
+ },
14433
+ inet: {
14434
+ cidr: "inet",
14435
+ inet: "inet"
14436
+ },
14437
+ macaddr: {
14438
+ macaddr: "macaddr",
14439
+ macaddr8: "macaddr"
14440
+ },
14441
+ macaddr8: {
14442
+ macaddr: "macaddr8",
14443
+ macaddr8: "macaddr8"
14444
+ },
14445
+ bit: {
14446
+ bit: "bit",
14447
+ varbit: "bit"
14448
+ },
14449
+ varbit: {
14450
+ bit: "varbit",
14451
+ varbit: "varbit"
14452
+ },
14453
+ tsvector: { tsvector: "tsvector" },
14454
+ tsquery: { tsquery: "tsquery" },
14455
+ uuid: { uuid: "uuid" },
14456
+ xml: { xml: "xml" },
14457
+ json: { json: "json" },
14458
+ jsonb: { jsonb: "jsonb" },
14459
+ int4range: { int4range: "int4range" },
14460
+ int8range: { int8range: "int8range" },
14461
+ numrange: { numrange: "numrange" },
14462
+ tsrange: { tsrange: "tsrange" },
14463
+ tstzrange: { tstzrange: "tstzrange" },
14464
+ daterange: { daterange: "daterange" },
14465
+ int4multirange: { int4multirange: "int4multirange" },
14466
+ int8multirange: { int8multirange: "int8multirange" },
14467
+ nummultirange: { nummultirange: "nummultirange" },
14468
+ tsmultirange: { tsmultirange: "tsmultirange" },
14469
+ tstzmultirange: { tstzmultirange: "tstzmultirange" },
14470
+ datemultirange: { datemultirange: "datemultirange" },
14471
+ oid: {
14472
+ smallint: "oid",
14473
+ int: "oid",
14474
+ bigint: "oid",
14475
+ "bigint:number": "oid",
14476
+ "bigint:string": "oid",
14477
+ smallserial: "oid",
14478
+ serial: "oid",
14479
+ bigserial: "oid",
14480
+ "bigserial:number": "oid",
14481
+ oid: "oid",
14482
+ regproc: "oid",
14483
+ regprocedure: "oid",
14484
+ regoper: "oid",
14485
+ regoperator: "oid",
14486
+ regclass: "oid",
14487
+ regtype: "oid",
14488
+ regrole: "oid",
14489
+ regnamespace: "oid",
14490
+ regconfig: "oid",
14491
+ regdictionary: "oid"
14492
+ },
14493
+ regproc: {
14494
+ smallint: "regproc",
14495
+ int: "regproc",
14496
+ bigint: "regproc",
14497
+ "bigint:number": "regproc",
14498
+ "bigint:string": "regproc",
14499
+ smallserial: "regproc",
14500
+ serial: "regproc",
14501
+ bigserial: "regproc",
14502
+ "bigserial:number": "regproc",
14503
+ oid: "regproc",
14504
+ regproc: "regproc",
14505
+ regprocedure: "regproc"
14506
+ },
14507
+ regprocedure: {
14508
+ smallint: "regprocedure",
14509
+ int: "regprocedure",
14510
+ bigint: "regprocedure",
14511
+ "bigint:number": "regprocedure",
14512
+ "bigint:string": "regprocedure",
14513
+ smallserial: "regprocedure",
14514
+ serial: "regprocedure",
14515
+ bigserial: "regprocedure",
14516
+ "bigserial:number": "regprocedure",
14517
+ oid: "regprocedure",
14518
+ regproc: "regprocedure",
14519
+ regprocedure: "regprocedure"
14520
+ },
14521
+ regoper: {
14522
+ smallint: "regoper",
14523
+ int: "regoper",
14524
+ bigint: "regoper",
14525
+ "bigint:number": "regoper",
14526
+ "bigint:string": "regoper",
14527
+ smallserial: "regoper",
14528
+ serial: "regoper",
14529
+ bigserial: "regoper",
14530
+ "bigserial:number": "regoper",
14531
+ oid: "regoper",
14532
+ regoper: "regoper",
14533
+ regoperator: "regoper"
14534
+ },
14535
+ regoperator: {
14536
+ smallint: "regoperator",
14537
+ int: "regoperator",
14538
+ bigint: "regoperator",
14539
+ "bigint:number": "regoperator",
14540
+ "bigint:string": "regoperator",
14541
+ smallserial: "regoperator",
14542
+ serial: "regoperator",
14543
+ bigserial: "regoperator",
14544
+ "bigserial:number": "regoperator",
14545
+ oid: "regoperator",
14546
+ regoper: "regoperator",
14547
+ regoperator: "regoperator"
14548
+ },
14549
+ regclass: {
14550
+ smallint: "regclass",
14551
+ int: "regclass",
14552
+ bigint: "regclass",
14553
+ "bigint:number": "regclass",
14554
+ "bigint:string": "regclass",
14555
+ smallserial: "regclass",
14556
+ serial: "regclass",
14557
+ bigserial: "regclass",
14558
+ "bigserial:number": "regclass",
14559
+ oid: "regclass",
14560
+ regclass: "regclass"
14561
+ },
14562
+ regtype: {
14563
+ smallint: "regtype",
14564
+ int: "regtype",
14565
+ bigint: "regtype",
14566
+ "bigint:number": "regtype",
14567
+ "bigint:string": "regtype",
14568
+ smallserial: "regtype",
14569
+ serial: "regtype",
14570
+ bigserial: "regtype",
14571
+ "bigserial:number": "regtype",
14572
+ oid: "regtype",
14573
+ regtype: "regtype"
14574
+ },
14575
+ regrole: {
14576
+ smallint: "regrole",
14577
+ int: "regrole",
14578
+ bigint: "regrole",
14579
+ "bigint:number": "regrole",
14580
+ "bigint:string": "regrole",
14581
+ smallserial: "regrole",
14582
+ serial: "regrole",
14583
+ bigserial: "regrole",
14584
+ "bigserial:number": "regrole",
14585
+ oid: "regrole",
14586
+ regrole: "regrole"
14587
+ },
14588
+ regnamespace: {
14589
+ smallint: "regnamespace",
14590
+ int: "regnamespace",
14591
+ bigint: "regnamespace",
14592
+ "bigint:number": "regnamespace",
14593
+ "bigint:string": "regnamespace",
14594
+ smallserial: "regnamespace",
14595
+ serial: "regnamespace",
14596
+ bigserial: "regnamespace",
14597
+ "bigserial:number": "regnamespace",
14598
+ oid: "regnamespace",
14599
+ regnamespace: "regnamespace"
14600
+ },
14601
+ regconfig: {
14602
+ smallint: "regconfig",
14603
+ int: "regconfig",
14604
+ bigint: "regconfig",
14605
+ "bigint:number": "regconfig",
14606
+ "bigint:string": "regconfig",
14607
+ smallserial: "regconfig",
14608
+ serial: "regconfig",
14609
+ bigserial: "regconfig",
14610
+ "bigserial:number": "regconfig",
14611
+ oid: "regconfig",
14612
+ regconfig: "regconfig"
14613
+ },
14614
+ regdictionary: {
14615
+ smallint: "regdictionary",
14616
+ int: "regdictionary",
14617
+ bigint: "regdictionary",
14618
+ "bigint:number": "regdictionary",
14619
+ "bigint:string": "regdictionary",
14620
+ smallserial: "regdictionary",
14621
+ serial: "regdictionary",
14622
+ bigserial: "regdictionary",
14623
+ "bigserial:number": "regdictionary",
14624
+ oid: "regdictionary",
14625
+ regdictionary: "regdictionary"
14626
+ }
14263
14627
  };
14264
- function resolvePgTypeAlias(type) {
14265
- return PG_ALIAS_TO_TYPE_MAP[type] ?? type;
14266
- }
14267
14628
  var castToText = (name2) => sql`${name2}::text`;
14268
14629
  var castToTextArr = (name2, arrayDimensions) => sql`${name2}::text${sql.raw("[]".repeat(arrayDimensions))}`;
14269
14630
  var arrayCompatCast = (cast) => (name2, arrayDimensions) => {
@@ -14517,57 +14878,368 @@ var genericPgCodecs = {
14517
14878
  normalizeArrayInJson: arrayCompatNormalize(parsePgVector)
14518
14879
  }
14519
14880
  };
14520
- var refineGenericPgCodecs = (extension) => refineCodecs(genericPgCodecs, extension);
14881
+ var refineGenericPgCodecs = (extension) => refineCodecs(genericPgCodecs, extension);
14882
+
14883
+ // node_modules/drizzle-orm/pg-core/columns/custom.js
14884
+ var PgCustomColumnBuilder = class extends PgColumnBuilder {
14885
+ static [entityKind] = "PgCustomColumnBuilder";
14886
+ constructor(name2, fieldConfig, customTypeParams) {
14887
+ super(name2, "custom", "PgCustomColumn");
14888
+ this.config.fieldConfig = fieldConfig;
14889
+ this.config.customTypeParams = customTypeParams;
14890
+ }
14891
+ build(table) {
14892
+ return new PgCustomColumn(table, this.config);
14893
+ }
14894
+ };
14895
+ var PgCustomColumn = class extends PgColumn {
14896
+ static [entityKind] = "PgCustomColumn";
14897
+ codec;
14898
+ sqlName;
14899
+ mapFromJsonValue;
14900
+ jsonSelectIdentifier;
14901
+ constructor(table, config) {
14902
+ super(table, config);
14903
+ this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
14904
+ this.mapToDriverValue = config.customTypeParams.toDriver ?? this.mapToDriverValue;
14905
+ this.mapFromDriverValue = config.customTypeParams.fromDriver ?? this.mapFromDriverValue;
14906
+ this.mapFromJsonValue = config.customTypeParams.fromJson;
14907
+ this.jsonSelectIdentifier = config.customTypeParams.forJsonSelect;
14908
+ const cfgCodec = typeof config.customTypeParams.codec === "string" || typeof config.customTypeParams.codec === "undefined" ? config.customTypeParams.codec : config.customTypeParams.codec(config.fieldConfig);
14909
+ this.codec = typeof cfgCodec === "string" ? resolvePgTypeAlias(cfgCodec) : undefined;
14910
+ if (this.dimensions && config.customTypeParams.fromJson)
14911
+ this.mapFromJsonValue = (value) => {
14912
+ if (value === null)
14913
+ return value;
14914
+ const arr = typeof value === "string" ? parsePgArray(value) : value;
14915
+ return this.mapJsonArrayElements(arr, config.customTypeParams.fromJson, this.dimensions);
14916
+ };
14917
+ }
14918
+ mapJsonArrayElements(value, mapper, depth) {
14919
+ if (depth > 0 && Array.isArray(value))
14920
+ return value.map((v) => v === null ? null : this.mapJsonArrayElements(v, mapper, depth - 1));
14921
+ return mapper(value);
14922
+ }
14923
+ getSQLType() {
14924
+ return this.sqlName;
14925
+ }
14926
+ };
14927
+ function customType(customTypeParams) {
14928
+ return (a, b) => {
14929
+ const { name: name2, config } = getColumnNameAndConfig2(a, b);
14930
+ return new PgCustomColumnBuilder(name2, config, customTypeParams);
14931
+ };
14932
+ }
14933
+ // node_modules/drizzle-orm/pg-core/columns/double-precision.js
14934
+ var PgDoublePrecisionBuilder = class extends PgColumnBuilder {
14935
+ static [entityKind] = "PgDoublePrecisionBuilder";
14936
+ constructor(name2) {
14937
+ super(name2, "number double", "PgDoublePrecision");
14938
+ }
14939
+ build(table) {
14940
+ return new PgDoublePrecision(table, this.config);
14941
+ }
14942
+ };
14943
+ var PgDoublePrecision = class extends PgColumn {
14944
+ static [entityKind] = "PgDoublePrecision";
14945
+ codec = "float8";
14946
+ getSQLType() {
14947
+ return "double precision";
14948
+ }
14949
+ };
14950
+ function doublePrecision(name2) {
14951
+ return new PgDoublePrecisionBuilder(name2 ?? "");
14952
+ }
14953
+ // node_modules/drizzle-orm/pg-core/columns/integer.js
14954
+ var PgIntegerBuilder = class extends PgIntColumnBuilder {
14955
+ static [entityKind] = "PgIntegerBuilder";
14956
+ constructor(name2) {
14957
+ super(name2, "number int32", "PgInteger");
14958
+ }
14959
+ build(table) {
14960
+ return new PgInteger(table, this.config);
14961
+ }
14962
+ };
14963
+ var PgInteger = class extends PgColumn {
14964
+ static [entityKind] = "PgInteger";
14965
+ codec = "int";
14966
+ getSQLType() {
14967
+ return "integer";
14968
+ }
14969
+ };
14970
+ function integer(name2) {
14971
+ return new PgIntegerBuilder(name2 ?? "");
14972
+ }
14973
+ // node_modules/drizzle-orm/pg-core/columns/jsonb.js
14974
+ var PgJsonbBuilder = class extends PgColumnBuilder {
14975
+ static [entityKind] = "PgJsonbBuilder";
14976
+ constructor(name2) {
14977
+ super(name2, "object json", "PgJsonb");
14978
+ }
14979
+ build(table) {
14980
+ return new PgJsonb(table, this.config);
14981
+ }
14982
+ };
14983
+ var PgJsonb = class extends PgColumn {
14984
+ static [entityKind] = "PgJsonb";
14985
+ codec = "jsonb";
14986
+ constructor(table, config) {
14987
+ super(table, config);
14988
+ }
14989
+ getSQLType() {
14990
+ return "jsonb";
14991
+ }
14992
+ };
14993
+ function jsonb(name2) {
14994
+ return new PgJsonbBuilder(name2 ?? "");
14995
+ }
14996
+ // node_modules/drizzle-orm/pg-core/columns/smallint.js
14997
+ var PgSmallIntBuilder = class extends PgIntColumnBuilder {
14998
+ static [entityKind] = "PgSmallIntBuilder";
14999
+ constructor(name2) {
15000
+ super(name2, "number int16", "PgSmallInt");
15001
+ }
15002
+ build(table) {
15003
+ return new PgSmallInt(table, this.config);
15004
+ }
15005
+ };
15006
+ var PgSmallInt = class extends PgColumn {
15007
+ static [entityKind] = "PgSmallInt";
15008
+ codec = "smallint";
15009
+ getSQLType() {
15010
+ return "smallint";
15011
+ }
15012
+ };
15013
+ function smallint(name2) {
15014
+ return new PgSmallIntBuilder(name2 ?? "");
15015
+ }
15016
+ // node_modules/drizzle-orm/pg-core/columns/text.js
15017
+ var PgTextBuilder = class extends PgColumnBuilder {
15018
+ static [entityKind] = "PgTextBuilder";
15019
+ constructor(name2, config) {
15020
+ super(name2, config.enum?.length ? "string enum" : "string", "PgText");
15021
+ this.config.enumValues = config.enum;
15022
+ }
15023
+ build(table) {
15024
+ return new PgText(table, this.config, this.config.enumValues);
15025
+ }
15026
+ };
15027
+ var PgText = class extends PgColumn {
15028
+ static [entityKind] = "PgText";
15029
+ enumValues;
15030
+ codec = "text";
15031
+ constructor(table, config, enumValues) {
15032
+ super(table, config);
15033
+ this.enumValues = enumValues;
15034
+ }
15035
+ getSQLType() {
15036
+ return "text";
15037
+ }
15038
+ };
15039
+ function text(a, b = {}) {
15040
+ const { name: name2, config } = getColumnNameAndConfig2(a, b);
15041
+ return new PgTextBuilder(name2, config);
15042
+ }
15043
+ // node_modules/drizzle-orm/pg-core/columns/date.common.js
15044
+ var PgDateColumnBuilder = class extends PgColumnBuilder {
15045
+ static [entityKind] = "PgDateColumnBaseBuilder";
15046
+ defaultNow() {
15047
+ return this.default(sql`now()`);
15048
+ }
15049
+ };
15050
+
15051
+ // node_modules/drizzle-orm/pg-core/columns/timestamp.js
15052
+ var PgTimestampBuilder = class extends PgDateColumnBuilder {
15053
+ static [entityKind] = "PgTimestampBuilder";
15054
+ constructor(name2, withTimezone, precision) {
15055
+ super(name2, "object date", "PgTimestamp");
15056
+ this.config.withTimezone = withTimezone;
15057
+ this.config.precision = precision;
15058
+ }
15059
+ build(table) {
15060
+ return new PgTimestamp(table, this.config);
15061
+ }
15062
+ };
15063
+ var PgTimestamp = class extends PgColumn {
15064
+ static [entityKind] = "PgTimestamp";
15065
+ codec;
15066
+ withTimezone;
15067
+ precision;
15068
+ constructor(table, config) {
15069
+ super(table, config);
15070
+ this.withTimezone = config.withTimezone;
15071
+ this.precision = config.precision;
15072
+ this.codec = this.withTimezone ? "timestamptz" : "timestamp";
15073
+ }
15074
+ getSQLType() {
15075
+ return `timestamp${this.precision === undefined ? "" : ` (${this.precision})`}${this.withTimezone ? " with time zone" : ""}`;
15076
+ }
15077
+ mapToDriverValue = (value) => {
15078
+ if (typeof value === "string")
15079
+ return value;
15080
+ return value.toISOString();
15081
+ };
15082
+ };
15083
+ var PgTimestampStringBuilder = class extends PgDateColumnBuilder {
15084
+ static [entityKind] = "PgTimestampStringBuilder";
15085
+ constructor(name2, withTimezone, precision) {
15086
+ super(name2, "string timestamp", "PgTimestampString");
15087
+ this.config.withTimezone = withTimezone;
15088
+ this.config.precision = precision;
15089
+ }
15090
+ build(table) {
15091
+ return new PgTimestampString(table, this.config);
15092
+ }
15093
+ };
15094
+ var PgTimestampString = class extends PgColumn {
15095
+ static [entityKind] = "PgTimestampString";
15096
+ codec;
15097
+ withTimezone;
15098
+ precision;
15099
+ constructor(table, config) {
15100
+ super(table, config);
15101
+ this.withTimezone = config.withTimezone;
15102
+ this.precision = config.precision;
15103
+ this.codec = this.withTimezone ? "timestamptz:string" : "timestamp:string";
15104
+ }
15105
+ getSQLType() {
15106
+ return `timestamp${this.precision === undefined ? "" : `(${this.precision})`}${this.withTimezone ? " with time zone" : ""}`;
15107
+ }
15108
+ mapToDriverValue = (value) => {
15109
+ if (typeof value === "string")
15110
+ return value;
15111
+ return value.toISOString();
15112
+ };
15113
+ };
15114
+ function timestamp(a, b = {}) {
15115
+ const { name: name2, config } = getColumnNameAndConfig2(a, b);
15116
+ if (config?.mode === "string")
15117
+ return new PgTimestampStringBuilder(name2, config.withTimezone ?? false, config.precision);
15118
+ return new PgTimestampBuilder(name2, config?.withTimezone ?? false, config?.precision);
15119
+ }
15120
+ // node_modules/drizzle-orm/pg-core/columns/varchar.js
15121
+ var PgVarcharBuilder = class extends PgColumnBuilder {
15122
+ static [entityKind] = "PgVarcharBuilder";
15123
+ constructor(name2, config) {
15124
+ super(name2, config.enum?.length ? "string enum" : "string", "PgVarchar");
15125
+ this.config.length = config.length;
15126
+ this.config.enumValues = config.enum;
15127
+ }
15128
+ build(table) {
15129
+ return new PgVarchar(table, this.config);
15130
+ }
15131
+ };
15132
+ var PgVarchar = class extends PgColumn {
15133
+ static [entityKind] = "PgVarchar";
15134
+ codec = "varchar";
15135
+ enumValues;
15136
+ constructor(table, config) {
15137
+ super(table, config);
15138
+ this.enumValues = config.enumValues;
15139
+ }
15140
+ getSQLType() {
15141
+ return this.length === undefined ? `varchar` : `varchar(${this.length})`;
15142
+ }
15143
+ };
15144
+ function varchar(a, b = {}) {
15145
+ const { name: name2, config } = getColumnNameAndConfig2(a, b);
15146
+ return new PgVarcharBuilder(name2, config);
15147
+ }
15148
+ // node_modules/drizzle-orm/pg-core/columns/bigserial.js
15149
+ var PgBigSerial53Builder = class extends PgColumnBuilder {
15150
+ static [entityKind] = "PgBigSerial53Builder";
15151
+ constructor(name2) {
15152
+ super(name2, "number int53", "PgBigSerial53");
15153
+ this.config.hasDefault = true;
15154
+ this.config.notNull = true;
15155
+ }
15156
+ build(table) {
15157
+ return new PgBigSerial53(table, this.config);
15158
+ }
15159
+ };
15160
+ var PgBigSerial53 = class extends PgColumn {
15161
+ static [entityKind] = "PgBigSerial53";
15162
+ codec = "bigserial:number";
15163
+ getSQLType() {
15164
+ return "bigserial";
15165
+ }
15166
+ };
15167
+ var PgBigSerial64Builder = class extends PgColumnBuilder {
15168
+ static [entityKind] = "PgBigSerial64Builder";
15169
+ constructor(name2) {
15170
+ super(name2, "bigint int64", "PgBigSerial64");
15171
+ this.config.hasDefault = true;
15172
+ this.config.notNull = true;
15173
+ }
15174
+ build(table) {
15175
+ return new PgBigSerial64(table, this.config);
15176
+ }
15177
+ };
15178
+ var PgBigSerial64 = class extends PgColumn {
15179
+ static [entityKind] = "PgBigSerial64";
15180
+ codec = "bigserial";
15181
+ getSQLType() {
15182
+ return "bigserial";
15183
+ }
15184
+ };
15185
+ function bigserial(a, b) {
15186
+ const { name: name2, config } = getColumnNameAndConfig2(a, b);
15187
+ if (config.mode === "number")
15188
+ return new PgBigSerial53Builder(name2);
15189
+ return new PgBigSerial64Builder(name2);
15190
+ }
14521
15191
 
14522
- // node_modules/drizzle-orm/pg-core/columns/custom.js
14523
- var PgCustomColumnBuilder = class extends PgColumnBuilder {
14524
- static [entityKind] = "PgCustomColumnBuilder";
14525
- constructor(name2, fieldConfig, customTypeParams) {
14526
- super(name2, "custom", "PgCustomColumn");
14527
- this.config.fieldConfig = fieldConfig;
14528
- this.config.customTypeParams = customTypeParams;
15192
+ // node_modules/drizzle-orm/pg-core/columns/char.js
15193
+ var PgCharBuilder = class extends PgColumnBuilder {
15194
+ static [entityKind] = "PgCharBuilder";
15195
+ constructor(name2, config) {
15196
+ super(name2, config.enum?.length ? "string enum" : "string", "PgChar");
15197
+ this.config.length = config.length ?? 1;
15198
+ this.config.setLength = config.length !== undefined;
15199
+ this.config.enumValues = config.enum;
14529
15200
  }
14530
15201
  build(table) {
14531
- return new PgCustomColumn(table, this.config);
15202
+ return new PgChar(table, this.config);
14532
15203
  }
14533
15204
  };
14534
- var PgCustomColumn = class extends PgColumn {
14535
- static [entityKind] = "PgCustomColumn";
14536
- codec;
14537
- sqlName;
14538
- mapFromJsonValue;
14539
- jsonSelectIdentifier;
15205
+ var PgChar = class extends PgColumn {
15206
+ static [entityKind] = "PgChar";
15207
+ codec = "char";
15208
+ enumValues;
15209
+ setLength;
14540
15210
  constructor(table, config) {
14541
15211
  super(table, config);
14542
- this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
14543
- this.mapToDriverValue = config.customTypeParams.toDriver ?? this.mapToDriverValue;
14544
- this.mapFromDriverValue = config.customTypeParams.fromDriver ?? this.mapFromDriverValue;
14545
- this.mapFromJsonValue = config.customTypeParams.fromJson;
14546
- this.jsonSelectIdentifier = config.customTypeParams.forJsonSelect;
14547
- const cfgCodec = typeof config.customTypeParams.codec === "string" || typeof config.customTypeParams.codec === "undefined" ? config.customTypeParams.codec : config.customTypeParams.codec(config.fieldConfig);
14548
- this.codec = typeof cfgCodec === "string" ? resolvePgTypeAlias(cfgCodec) : undefined;
14549
- if (this.dimensions && config.customTypeParams.fromJson)
14550
- this.mapFromJsonValue = (value) => {
14551
- if (value === null)
14552
- return value;
14553
- const arr = typeof value === "string" ? parsePgArray(value) : value;
14554
- return this.mapJsonArrayElements(arr, config.customTypeParams.fromJson, this.dimensions);
14555
- };
15212
+ this.enumValues = config.enumValues;
15213
+ this.setLength = config.setLength;
14556
15214
  }
14557
- mapJsonArrayElements(value, mapper, depth) {
14558
- if (depth > 0 && Array.isArray(value))
14559
- return value.map((v) => v === null ? null : this.mapJsonArrayElements(v, mapper, depth - 1));
14560
- return mapper(value);
15215
+ getSQLType() {
15216
+ return this.setLength ? `char(${this.length})` : `char`;
15217
+ }
15218
+ };
15219
+ function char(a, b = {}) {
15220
+ const { name: name2, config } = getColumnNameAndConfig2(a, b);
15221
+ return new PgCharBuilder(name2, config);
15222
+ }
15223
+
15224
+ // node_modules/drizzle-orm/pg-core/columns/cidr.js
15225
+ var PgCidrBuilder = class extends PgColumnBuilder {
15226
+ static [entityKind] = "PgCidrBuilder";
15227
+ constructor(name2) {
15228
+ super(name2, "string cidr", "PgCidr");
14561
15229
  }
15230
+ build(table) {
15231
+ return new PgCidr(table, this.config);
15232
+ }
15233
+ };
15234
+ var PgCidr = class extends PgColumn {
15235
+ static [entityKind] = "PgCidr";
15236
+ codec = "cidr";
14562
15237
  getSQLType() {
14563
- return this.sqlName;
15238
+ return "cidr";
14564
15239
  }
14565
15240
  };
14566
- function customType(customTypeParams) {
14567
- return (a, b) => {
14568
- const { name: name2, config } = getColumnNameAndConfig2(a, b);
14569
- return new PgCustomColumnBuilder(name2, config, customTypeParams);
14570
- };
15241
+ function cidr(name2) {
15242
+ return new PgCidrBuilder(name2 ?? "");
14571
15243
  }
14572
15244
 
14573
15245
  // node_modules/drizzle-orm/pg-core/columns/date.js
@@ -20581,12 +21253,12 @@ async function hashQuery(sql2, params) {
20581
21253
  var PgCountBuilder = class PgCountBuilder2 extends SQL {
20582
21254
  static [entityKind] = "PgCountBuilder";
20583
21255
  dialect;
20584
- static buildEmbeddedCount(source, filters, parens) {
21256
+ static buildCount(source, filters, parens) {
20585
21257
  const query = sql`select count(*) from ${source}${sql` where ${filters}`.if(filters)}`;
20586
21258
  return parens ? sql`(${query})` : query;
20587
21259
  }
20588
21260
  constructor(countConfig) {
20589
- super(PgCountBuilder2.buildEmbeddedCount(countConfig.source, countConfig.filters, true).queryChunks);
21261
+ super(PgCountBuilder2.buildCount(countConfig.source, countConfig.filters, true).queryChunks);
20590
21262
  this.countConfig = countConfig;
20591
21263
  this.dialect = countConfig.dialect;
20592
21264
  this.mapWith((e) => {
@@ -20595,10 +21267,13 @@ var PgCountBuilder = class PgCountBuilder2 extends SQL {
20595
21267
  return Number(e ?? 0);
20596
21268
  });
20597
21269
  }
21270
+ executableSql;
20598
21271
  build() {
20599
- const { filters, source } = this.countConfig;
20600
- const query = PgCountBuilder2.buildEmbeddedCount(source, filters);
20601
- return this.dialect.sqlToQuery(query);
21272
+ if (!this.executableSql) {
21273
+ const { source, filters } = this.countConfig;
21274
+ this.executableSql = PgCountBuilder2.buildCount(source, filters);
21275
+ }
21276
+ return this.dialect.sqlToQuery(this.executableSql);
20602
21277
  }
20603
21278
  };
20604
21279
 
@@ -20850,7 +21525,6 @@ var SelectionProxyHandler = class SelectionProxyHandler2 {
20850
21525
  var PgDeleteBase2 = class {
20851
21526
  static [entityKind] = "PgDelete";
20852
21527
  config;
20853
- cacheConfig;
20854
21528
  constructor(table, session, dialect, withList) {
20855
21529
  this.session = session;
20856
21530
  this.dialect = dialect;
@@ -20898,7 +21572,7 @@ var PgDeleteBase2 = class {
20898
21572
  var PgAsyncDeleteBase2 = class extends PgDeleteBase2 {
20899
21573
  static [entityKind] = "PgAsyncDelete";
20900
21574
  _prepare(name2, generateName = false) {
20901
- const { session, config, dialect, cacheConfig } = this;
21575
+ const { session, config, dialect } = this;
20902
21576
  const { returning: fields } = config;
20903
21577
  return tracer.startActiveSpan("drizzle.prepareQuery", () => {
20904
21578
  const query = dialect.sqlToQuery(this.getSQL());
@@ -20906,7 +21580,7 @@ var PgAsyncDeleteBase2 = class extends PgDeleteBase2 {
20906
21580
  return session.prepareQuery(query, fields ? "arrays" : "raw", name2 ?? generateName, mapper, {
20907
21581
  type: "delete",
20908
21582
  tables: [...extractUsedTable(this.config.table)]
20909
- }, cacheConfig);
21583
+ });
20910
21584
  });
20911
21585
  }
20912
21586
  prepare(name2) {
@@ -20953,7 +21627,6 @@ var PgSelectBuilder2 = class {
20953
21627
  if (config.withList)
20954
21628
  this.withList = config.withList;
20955
21629
  this.distinct = config.distinct;
20956
- this.tagged = config.tagged;
20957
21630
  }
20958
21631
  from(source) {
20959
21632
  const isPartialSelect = !!this.fields;
@@ -20976,8 +21649,7 @@ var PgSelectBuilder2 = class {
20976
21649
  session: this.session,
20977
21650
  dialect: this.dialect,
20978
21651
  withList: this.withList,
20979
- distinct: this.distinct,
20980
- tagged: this.tagged
21652
+ distinct: this.distinct
20981
21653
  });
20982
21654
  }
20983
21655
  };
@@ -21001,8 +21673,7 @@ var PgSelectBase2 = class extends TypedQueryBuilder {
21001
21673
  table: config.table,
21002
21674
  fields: { ...config.fields },
21003
21675
  distinct: config.distinct,
21004
- setOperators: [],
21005
- _tagged: config.tagged
21676
+ setOperators: []
21006
21677
  };
21007
21678
  this.isPartialSelect = config.isPartialSelect;
21008
21679
  this._ = {
@@ -21179,6 +21850,7 @@ var PgSelectBase2 = class extends TypedQueryBuilder {
21179
21850
  return this;
21180
21851
  }
21181
21852
  getSQL() {
21853
+ this.config.fieldsFlat = orderSelectedFields2(this.config.fields, undefined, this.dialect.codecs);
21182
21854
  return this.dialect.buildSelectQuery(this.config);
21183
21855
  }
21184
21856
  toSQL() {
@@ -21274,7 +21946,6 @@ params: ${params}`);
21274
21946
  this.cause = cause;
21275
21947
  }
21276
21948
  };
21277
-
21278
21949
  // node_modules/drizzle-orm/relations.js
21279
21950
  var Relation2 = class {
21280
21951
  static [entityKind] = "RelationV2";
@@ -21355,15 +22026,13 @@ var orderByOperators2 = {
21355
22026
  asc,
21356
22027
  desc
21357
22028
  };
21358
- function mapRelationalRow2(rows, isOne, buildQueryResultSelection, mapColumnValue, parseJson = false, parseJsonIfString = false, useJsonMappers = true) {
22029
+ function mapRelationalRow2(rows, isOne, buildQueryResultSelection, parseJson = false, parseJsonIfString = false, useJsonMappers = true) {
21359
22030
  const maxIdx = isOne ? 1 : rows.length;
21360
22031
  const decoders = buildQueryResultSelection.map(({ field, codec, arrayDimensions }) => {
21361
22032
  let decoder;
21362
- if (is(field, Column)) {
21363
- if (useJsonMappers && field.mapFromJsonValue)
21364
- return (v2) => field.mapFromJsonValue(v2);
22033
+ if (is(field, Column))
21365
22034
  decoder = field;
21366
- } else if (is(field, SQL))
22035
+ else if (is(field, SQL))
21367
22036
  decoder = field.decoder;
21368
22037
  else if (is(field, SQL.Aliased))
21369
22038
  decoder = field.sql.decoder;
@@ -21371,6 +22040,8 @@ function mapRelationalRow2(rows, isOne, buildQueryResultSelection, mapColumnValu
21371
22040
  decoder = noopDecoder;
21372
22041
  else
21373
22042
  decoder = field.getSQL().decoder;
22043
+ if (useJsonMappers && field.mapFromJsonValue)
22044
+ return (v2) => field.mapFromJsonValue(v2);
21374
22045
  return decoder.mapFromDriverValue.isNoop ? codec ? (value) => codec(value, arrayDimensions) : undefined : codec ? (value) => decoder.mapFromDriverValue(codec(value, arrayDimensions)) : (value) => decoder.mapFromDriverValue(value);
21375
22046
  });
21376
22047
  for (let i = 0;i < maxIdx; ++i) {
@@ -21387,14 +22058,12 @@ function mapRelationalRow2(rows, isOne, buildQueryResultSelection, mapColumnValu
21387
22058
  } else if (parseJsonIfString && typeof row[selectionItem.key] === "string")
21388
22059
  row[selectionItem.key] = JSON.parse(row[selectionItem.key]);
21389
22060
  if (selectionItem.isArray) {
21390
- mapRelationalRow2(row[selectionItem.key], false, selectionItem.selection, mapColumnValue, false, parseJsonIfString);
22061
+ mapRelationalRow2(row[selectionItem.key], false, selectionItem.selection, false, parseJsonIfString);
21391
22062
  continue;
21392
22063
  }
21393
- mapRelationalRow2(row[selectionItem.key], true, selectionItem.selection, mapColumnValue, false, parseJsonIfString);
22064
+ mapRelationalRow2(row[selectionItem.key], true, selectionItem.selection, false, parseJsonIfString);
21394
22065
  continue;
21395
22066
  }
21396
- if (mapColumnValue)
21397
- row[selectionItem.key] = mapColumnValue(row[selectionItem.key]);
21398
22067
  if (row[selectionItem.key] === null)
21399
22068
  continue;
21400
22069
  const decoder = decoders[selectionItemIdx];
@@ -21405,7 +22074,7 @@ function mapRelationalRow2(rows, isOne, buildQueryResultSelection, mapColumnValu
21405
22074
  }
21406
22075
  return rows;
21407
22076
  }
21408
- function mapRelationalRowFromArrays2(rows, isOne, buildQueryResultSelection, mapColumnValue, parseJson = false, parseJsonIfString = false) {
22077
+ function mapRelationalRowFromArrays2(rows, isOne, buildQueryResultSelection, parseJson = false, parseJsonIfString = false) {
21409
22078
  const maxIdx = isOne ? 1 : rows.length;
21410
22079
  const decoders = buildQueryResultSelection.map(({ field, codec, arrayDimensions }) => {
21411
22080
  let decoder;
@@ -21442,14 +22111,12 @@ function mapRelationalRowFromArrays2(rows, isOne, buildQueryResultSelection, map
21442
22111
  } else if (parseJsonIfString && typeof value === "string")
21443
22112
  value = JSON.parse(value);
21444
22113
  if (selectionItem.isArray)
21445
- mapRelationalRow2(value, false, selectionItem.selection, mapColumnValue, false, parseJsonIfString);
22114
+ mapRelationalRow2(value, false, selectionItem.selection, false, parseJsonIfString);
21446
22115
  else
21447
- mapRelationalRow2(value, true, selectionItem.selection, mapColumnValue, false, parseJsonIfString);
22116
+ mapRelationalRow2(value, true, selectionItem.selection, false, parseJsonIfString);
21448
22117
  result[selectionItem.key] = value;
21449
22118
  continue;
21450
22119
  }
21451
- if (mapColumnValue)
21452
- value = mapColumnValue(value);
21453
22120
  if (value === null) {
21454
22121
  result[selectionItem.key] = null;
21455
22122
  continue;
@@ -21461,14 +22128,14 @@ function mapRelationalRowFromArrays2(rows, isOne, buildQueryResultSelection, map
21461
22128
  }
21462
22129
  return isOne ? results[0] : results;
21463
22130
  }
21464
- function makeDefaultRqbMapper2({ selection, isFirst, parseJson, parseJsonIfString, rootJsonMappers, arrayModeRoot }, mapColumnValue) {
22131
+ function makeDefaultRqbMapper2({ selection, isFirst, parseJson, parseJsonIfString, rootJsonMappers, arrayModeRoot }) {
21465
22132
  return (rows) => {
21466
22133
  if (isFirst && !rows[0])
21467
22134
  return rows[0];
21468
- return arrayModeRoot ? mapRelationalRowFromArrays2(isFirst ? rows[0] : rows, isFirst, selection, mapColumnValue, parseJson, parseJsonIfString) : mapRelationalRow2(isFirst ? rows[0] : rows, isFirst, selection, mapColumnValue, parseJson, parseJsonIfString, rootJsonMappers);
22135
+ return arrayModeRoot ? mapRelationalRowFromArrays2(isFirst ? rows[0] : rows, isFirst, selection, parseJson, parseJsonIfString) : mapRelationalRow2(isFirst ? rows[0] : rows, isFirst, selection, parseJson, parseJsonIfString, rootJsonMappers);
21469
22136
  };
21470
22137
  }
21471
- function makeJitRqbMapperInner(selection, rowExpr, selectionVar, mapColumnValue, parseJson, parseJsonIfString, useJsonMappers, preFn, counter, accessByIdx) {
22138
+ function makeJitRqbMapperInner(selection, rowExpr, selectionVar, parseJson, parseJsonIfString, useJsonMappers, preFn, counter, accessByIdx) {
21472
22139
  const bodyStmts = [];
21473
22140
  const literalEntries = [];
21474
22141
  let hasWork = false;
@@ -21492,7 +22159,7 @@ function makeJitRqbMapperInner(selection, rowExpr, selectionVar, mapColumnValue,
21492
22159
  preFn.push(`const { selection: ${nestedSelVar} } = ${sel};`);
21493
22160
  if (isArray) {
21494
22161
  const j = `j${counter.n++}`;
21495
- const inner = makeJitRqbMapperInner(innerSelection, `${slot}[${j}]`, nestedSelVar, mapColumnValue, false, parseJsonIfString, true, preFn, counter, false);
22162
+ const inner = makeJitRqbMapperInner(innerSelection, `${slot}[${j}]`, nestedSelVar, false, parseJsonIfString, true, preFn, counter, false);
21496
22163
  if (inner.hasWork) {
21497
22164
  hasWork = true;
21498
22165
  bodyStmts.push(`if (${slot} !== null) {`);
@@ -21505,7 +22172,7 @@ function makeJitRqbMapperInner(selection, rowExpr, selectionVar, mapColumnValue,
21505
22172
  } else
21506
22173
  preFn.splice(savedPreFnLen, 1);
21507
22174
  } else {
21508
- const inner = makeJitRqbMapperInner(innerSelection, slot, nestedSelVar, mapColumnValue, false, parseJsonIfString, true, preFn, counter, false);
22175
+ const inner = makeJitRqbMapperInner(innerSelection, slot, nestedSelVar, false, parseJsonIfString, true, preFn, counter, false);
21509
22176
  if (inner.hasWork) {
21510
22177
  hasWork = true;
21511
22178
  bodyStmts.push(`if (${slot} !== null) {`);
@@ -21534,21 +22201,39 @@ function makeJitRqbMapperInner(selection, rowExpr, selectionVar, mapColumnValue,
21534
22201
  decoderExpr = `dec${id}.mapFromDriverValue`;
21535
22202
  }
21536
22203
  } else if (is(field, SQL)) {
21537
- if (!field.decoder.mapFromDriverValue.isNoop) {
22204
+ if (useJsonMappers && field.decoder.mapFromJsonValue) {
22205
+ bypassCodecs = true;
22206
+ const id = counter.n++;
22207
+ destructure = `field: { decoder: dec${id} }`;
22208
+ decoderExpr = `dec${id}.mapFromJsonValue`;
22209
+ } else if (!field.decoder.mapFromDriverValue.isNoop) {
21538
22210
  const id = counter.n++;
21539
22211
  destructure = `field: { decoder: dec${id} }`;
21540
22212
  decoderExpr = `dec${id}.mapFromDriverValue`;
21541
22213
  }
21542
22214
  } else if (is(field, SQL.Aliased)) {
21543
- if (!field.sql.decoder.mapFromDriverValue.isNoop) {
22215
+ if (useJsonMappers && field.sql.decoder.mapFromJsonValue) {
22216
+ bypassCodecs = true;
22217
+ const id = counter.n++;
22218
+ destructure = `field: { sql: { decoder: dec${id} } }`;
22219
+ decoderExpr = `dec${id}.mapFromJsonValue`;
22220
+ } else if (!field.sql.decoder.mapFromDriverValue.isNoop) {
21544
22221
  const id = counter.n++;
21545
22222
  destructure = `field: { sql: { decoder: dec${id} } }`;
21546
22223
  decoderExpr = `dec${id}.mapFromDriverValue`;
21547
22224
  }
21548
- } else if (is(field, Table) || is(field, View)) {} else if (!field.getSQL().decoder.mapFromDriverValue.isNoop) {
21549
- const id = counter.n++;
21550
- preFn.push(`const dec${id} = ${sel}.field.getSQL().decoder;`);
21551
- decoderExpr = `dec${id}.mapFromDriverValue`;
22225
+ } else if (is(field, Table) || is(field, View)) {} else {
22226
+ const sqlExpr = field.getSQL();
22227
+ if (useJsonMappers && sqlExpr.decoder.mapFromJsonValue) {
22228
+ bypassCodecs = true;
22229
+ const id = counter.n++;
22230
+ preFn.push(`const dec${id} = ${sel}.field.getSQL().decoder;`);
22231
+ decoderExpr = `dec${id}.mapFromJsonValue`;
22232
+ } else if (!sqlExpr.decoder.mapFromDriverValue.isNoop) {
22233
+ const id = counter.n++;
22234
+ preFn.push(`const dec${id} = ${sel}.field.getSQL().decoder;`);
22235
+ decoderExpr = `dec${id}.mapFromDriverValue`;
22236
+ }
21552
22237
  }
21553
22238
  let codecVar = "";
21554
22239
  if (!bypassCodecs && codec)
@@ -21561,19 +22246,7 @@ function makeJitRqbMapperInner(selection, rowExpr, selectionVar, mapColumnValue,
21561
22246
  parts.push(`codec: ${codecVar}`);
21562
22247
  preFn.push(`const { ${parts.join(", ")} } = ${sel};`);
21563
22248
  }
21564
- if (mapColumnValue) {
21565
- hasWork = true;
21566
- bodyStmts.push(`${slot} = mapColumnValue(${slot});`);
21567
- if (decoderExpr || codecVar) {
21568
- let decoded = slot;
21569
- if (codecVar)
21570
- decoded = `${codecVar}(${decoded}, ${arrayDimensions})`;
21571
- if (decoderExpr)
21572
- decoded = `${decoderExpr}(${decoded})`;
21573
- bodyStmts.push(`if (${slot} !== null) ${slot} = ${decoded};`);
21574
- }
21575
- literalEntries.push(`${keyStr}: ${slot}`);
21576
- } else if (decoderExpr || codecVar) {
22249
+ if (decoderExpr || codecVar) {
21577
22250
  hasWork = true;
21578
22251
  let decoded = slot;
21579
22252
  if (codecVar)
@@ -21590,12 +22263,12 @@ function makeJitRqbMapperInner(selection, rowExpr, selectionVar, mapColumnValue,
21590
22263
  hasWork
21591
22264
  };
21592
22265
  }
21593
- function makeJitRqbMapper2({ selection, isFirst, parseJson, parseJsonIfString, rootJsonMappers, arrayModeRoot }, mapColumnValue) {
22266
+ function makeJitRqbMapper2({ selection, isFirst, parseJson, parseJsonIfString, rootJsonMappers, arrayModeRoot }) {
21594
22267
  const preFn = [];
21595
- const inner = makeJitRqbMapperInner(selection, "row", "selection", mapColumnValue, parseJson, parseJsonIfString, arrayModeRoot ? false : rootJsonMappers, preFn, { n: 0 }, !!arrayModeRoot);
22268
+ const inner = makeJitRqbMapperInner(selection, "row", "selection", parseJson, parseJsonIfString, arrayModeRoot ? false : rootJsonMappers, preFn, { n: 0 }, !!arrayModeRoot);
21596
22269
  const lines = [];
21597
22270
  lines.push(` "use strict";
21598
- const { selection${mapColumnValue ? `, mapColumnValue` : ""} } = this;`);
22271
+ const { selection } = this;`);
21599
22272
  for (const p2 of preFn)
21600
22273
  lines.push(` ${p2}`);
21601
22274
  if (arrayModeRoot)
@@ -21637,10 +22310,7 @@ function makeJitRqbMapper2({ selection, isFirst, parseJson, parseJsonIfString, r
21637
22310
  lines.push("\t//# sourceURL=drizzle:jit-relational-query-mapper");
21638
22311
  const compiled = lines.join(`
21639
22312
  `);
21640
- return Object.assign(new FnConstructor2("rows", compiled).bind({
21641
- selection,
21642
- mapColumnValue
21643
- }), { body: `function jitRqbMapper (rows) {
22313
+ return Object.assign(new FnConstructor2("rows", compiled).bind({ selection }), { body: `function jitRqbMapper (rows) {
21644
22314
  ${compiled}
21645
22315
  }` });
21646
22316
  }
@@ -21763,17 +22433,23 @@ function relationsOrderToSQL2(table, orders) {
21763
22433
  return;
21764
22434
  return sql.join(entries.map(([target, value]) => (value === "asc" ? asc : desc)(fieldSelectionToSQL2(table, target))), sql`, `);
21765
22435
  }
21766
- function relationExtrasToSQL2(table, extras) {
22436
+ function relationExtrasToSQL2(table, extras, codecs, inJson) {
21767
22437
  const subqueries = [];
21768
22438
  const selection = [];
21769
22439
  for (const [key, field] of Object.entries(extras)) {
21770
22440
  if (!field)
21771
22441
  continue;
21772
- const extra = typeof field === "function" ? field(table, { sql: operators2.sql }) : field;
21773
- const query = sql`(${extra.getSQL()}) as ${sql.identifier(key)}`;
21774
- query.decoder = extra.getSQL().decoder;
22442
+ const subq = (typeof field === "function" ? field(table, { sql: operators2.sql }) : field).getSQL();
22443
+ const column = codecs ? getColumnFromDecoder2(subq) : undefined;
22444
+ 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)}`;
22445
+ query.decoder = subq.decoder;
21775
22446
  subqueries.push(query);
21776
- selection.push({
22447
+ selection.push(column && (!inJson || !column.mapFromJsonValue) ? {
22448
+ key,
22449
+ field: query,
22450
+ codec: codecs.get(column, inJson ? "normalizeInJson" : "normalize"),
22451
+ arrayDimensions: column.dimensions
22452
+ } : {
21777
22453
  key,
21778
22454
  field: query
21779
22455
  });
@@ -21882,43 +22558,58 @@ var PgDialect2 = class {
21882
22558
  }
21883
22559
  buildSelection(fields, { isSingleTable = false, ignoreCastCodecs = false } = {}) {
21884
22560
  const columnsLen = fields.length;
21885
- const chunks = fields.flatMap(({ field }, i) => {
22561
+ const chunks = fields.flatMap(({ field, codecOverride, column }, i) => {
21886
22562
  const chunk = [];
21887
- if (is(field, SQL.Aliased) && field.isSelectionField) {
21888
- if (!isSingleTable && field.origin !== undefined)
21889
- chunk.push(sql.identifier(field.origin), sql.raw("."));
21890
- chunk.push(sql.identifier(field.fieldAlias));
21891
- } else if (is(field, SQL.Aliased) || is(field, SQL)) {
21892
- const query = is(field, SQL.Aliased) ? field.sql : field;
22563
+ const override = codecOverride;
22564
+ if (is(field, SQL.Aliased))
22565
+ if (field.isSelectionField) {
22566
+ const query = !isSingleTable && field.origin !== undefined ? sql`${sql.identifier(field.origin)}.${sql.identifier(field.fieldAlias)}` : sql.identifier(field.fieldAlias);
22567
+ if (column && !ignoreCastCodecs)
22568
+ chunk.push(this.codecs.apply(column, "cast", query, override));
22569
+ else
22570
+ chunk.push(query);
22571
+ } else {
22572
+ const query = field.sql;
22573
+ if (isSingleTable) {
22574
+ const newSql = new SQL(query.queryChunks.map((c) => {
22575
+ if (is(c, PgColumn))
22576
+ return sql.identifier(c.name);
22577
+ return c;
22578
+ }));
22579
+ if (query.shouldInlineParams)
22580
+ newSql.inlineParams();
22581
+ chunk.push(column && !ignoreCastCodecs ? this.codecs.apply(column, "cast", newSql, override) : newSql);
22582
+ } else
22583
+ chunk.push(column && !ignoreCastCodecs ? this.codecs.apply(column, "cast", query, override) : query);
22584
+ chunk.push(sql` as ${sql.identifier(field.fieldAlias)}`);
22585
+ }
22586
+ else if (is(field, SQL)) {
22587
+ const query = field;
21893
22588
  if (isSingleTable) {
21894
22589
  const newSql = new SQL(query.queryChunks.map((c) => {
21895
22590
  if (is(c, PgColumn))
21896
22591
  return sql.identifier(c.name);
21897
22592
  return c;
21898
22593
  }));
21899
- chunk.push(query.shouldInlineParams ? newSql.inlineParams() : newSql);
22594
+ if (query.shouldInlineParams)
22595
+ newSql.inlineParams();
22596
+ chunk.push(column && !ignoreCastCodecs ? this.codecs.apply(column, "cast", newSql, override) : newSql);
21900
22597
  } else
21901
- chunk.push(query);
21902
- if (is(field, SQL.Aliased))
21903
- chunk.push(sql` as ${sql.identifier(field.fieldAlias)}`);
22598
+ chunk.push(column && !ignoreCastCodecs ? this.codecs.apply(column, "cast", query, override) : query);
21904
22599
  } else if (is(field, Column)) {
21905
22600
  let name2;
21906
22601
  if (isSingleTable)
21907
22602
  name2 = field.isAlias ? sql.identifier(getOriginalColumnFromAlias2(field).name) : sql.identifier(field.name);
21908
22603
  else
21909
22604
  name2 = field.isAlias ? getOriginalColumnFromAlias2(field) : field;
21910
- const casted = ignoreCastCodecs ? name2 : this.codecs.apply(field, "cast", name2);
22605
+ const casted = ignoreCastCodecs ? name2 : this.codecs.apply(field, "cast", name2, override);
21911
22606
  chunk.push(field.isAlias ? sql`${casted} as ${field}` : casted);
21912
- } else if (is(field, Subquery)) {
21913
- const entries = Object.entries(field._.selectedFields);
21914
- if (entries.length === 1) {
21915
- const entry = entries[0][1];
21916
- const fieldDecoder = is(entry, SQL) ? entry.decoder : is(entry, Column) ? { mapFromDriverValue: (v2) => entry.mapFromDriverValue(v2) } : entry.sql.decoder;
21917
- if (fieldDecoder)
21918
- field._.sql.decoder = fieldDecoder;
21919
- }
21920
- chunk.push(field);
21921
- }
22607
+ } else if (is(field, Subquery))
22608
+ if (column && !ignoreCastCodecs && !field._.isWith) {
22609
+ const innerCasted = this.codecs.apply(column, "cast", sql`(${field._.sql})`, override);
22610
+ chunk.push(sql`${innerCasted} ${sql.identifier(field._.alias)}`);
22611
+ } else
22612
+ chunk.push(column ? this.codecs.apply(column, "cast", field) : field, override);
21922
22613
  if (i < columnsLen - 1)
21923
22614
  chunk.push(sql`, `);
21924
22615
  return chunk;
@@ -21969,8 +22660,10 @@ var PgDialect2 = class {
21969
22660
  }
21970
22661
  return table;
21971
22662
  }
21972
- buildSelectQuery({ withList, fields, fieldsFlat, where, having, table, joins, orderBy, groupBy, limit, offset, lockingClause, distinct, setOperators, comment, ignoreSelectionCastCodecs }) {
21973
- const fieldsList = fieldsFlat ?? orderSelectedFields2(fields, undefined, this.codecs);
22663
+ buildSelectQuery({ withList, fieldsFlat, where, having, table, joins, orderBy, groupBy, limit, offset, lockingClause, distinct, setOperators, comment, ignoreSelectionCastCodecs }) {
22664
+ if (!fieldsFlat)
22665
+ throw new Error("Select query builder must be provided with `fieldsFlat` on `buildSelectQuery` invocation");
22666
+ const fieldsList = fieldsFlat;
21974
22667
  for (const f of fieldsList)
21975
22668
  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)) {
21976
22669
  const tableName = getTableName(f.field.table);
@@ -21983,7 +22676,7 @@ var PgDialect2 = class {
21983
22676
  distinctSql = distinct === true ? sql` distinct` : sql` distinct on (${sql.join(distinct.on, sql`, `)})`;
21984
22677
  const selection = this.buildSelection(fieldsList, {
21985
22678
  isSingleTable,
21986
- ignoreCastCodecs: ignoreSelectionCastCodecs
22679
+ ignoreCastCodecs: ignoreSelectionCastCodecs || setOperators.length > 0
21987
22680
  });
21988
22681
  const tableSql = this.buildFromTable(table);
21989
22682
  const joinsSql = this.buildJoins(joins);
@@ -22010,26 +22703,67 @@ var PgDialect2 = class {
22010
22703
  }
22011
22704
  const finalQuery = sql`${withSql}select${distinctSql} ${selection} from ${tableSql}${joinsSql}${whereSql}${groupBySql}${havingSql}${orderBySql}${limitSql}${offsetSql}${lockingClauseSql}${comment !== undefined ? sql` ${comment}` : undefined}`;
22012
22705
  if (setOperators.length > 0)
22013
- return this.buildSetOperations(finalQuery, setOperators);
22706
+ return this.buildSetOperations(finalQuery, fieldsList, ignoreSelectionCastCodecs, setOperators);
22014
22707
  return finalQuery;
22015
22708
  }
22016
- buildSetOperations(leftSelect, setOperators) {
22017
- const [setOperator, ...rest] = setOperators;
22018
- if (!setOperator)
22019
- throw new Error("Cannot pass undefined values to any set operator");
22020
- if (rest.length === 0)
22021
- return this.buildSetOperationQuery({
22709
+ buildSetOperations(leftSelect, leftSelection, ignoreSelectionCastCodecs, setOperators) {
22710
+ const outputSelection = leftSelection;
22711
+ for (let i = 0;i < setOperators.length; ++i) {
22712
+ const setOperator = setOperators[i];
22713
+ if (!setOperator)
22714
+ throw new Error("Cannot pass undefined values to any set operator");
22715
+ leftSelect = this.buildSetOperationQuery({
22022
22716
  leftSelect,
22023
22717
  setOperator
22024
22718
  });
22025
- return this.buildSetOperations(this.buildSetOperationQuery({
22026
- leftSelect,
22027
- setOperator
22028
- }), rest);
22719
+ const rightSelection = orderSelectedFields2(setOperator.rightSelect.getSelectedFields());
22720
+ for (let j = 0;j < outputSelection.length; ++j) {
22721
+ const l = outputSelection[j];
22722
+ const lPath = l.path.join(".");
22723
+ const r = rightSelection.find((e) => e.path.join(".") === lPath);
22724
+ const lc = l.codecOverride ?? l.column?.codec;
22725
+ const rc = r.codecOverride ?? r.column?.codec;
22726
+ outputSelection[j].codecOverride = lc && rc ? unionsTypeTable[lc]?.[rc] : lc;
22727
+ }
22728
+ }
22729
+ for (let i = 0;i < outputSelection.length; ++i) {
22730
+ const out = outputSelection[i];
22731
+ out.codec = out.codecOverride ? this.codecs.get(out.column, "normalize", out.codecOverride) : out.codec;
22732
+ }
22733
+ return ignoreSelectionCastCodecs ? leftSelect : sql`select ${this.buildSelection(outputSelection.map((field) => {
22734
+ if (is(field.field, SQL.Aliased)) {
22735
+ const ref = field.field.clone();
22736
+ ref.isSelectionField = true;
22737
+ return {
22738
+ ...field,
22739
+ field: ref
22740
+ };
22741
+ }
22742
+ if (is(field.field, Column) && field.field.isAlias) {
22743
+ const ref = new SQL.Aliased(sql`${sql.identifier(field.field.name)}`, field.field.name);
22744
+ ref.isSelectionField = true;
22745
+ return {
22746
+ ...field,
22747
+ field: ref
22748
+ };
22749
+ }
22750
+ if (is(field.field, Subquery)) {
22751
+ const ref = new SQL.Aliased(sql`${field.field.getSQL()}`, field.field._.alias);
22752
+ ref.isSelectionField = true;
22753
+ return {
22754
+ ...field,
22755
+ field: ref
22756
+ };
22757
+ }
22758
+ return field;
22759
+ }), {
22760
+ isSingleTable: true,
22761
+ ignoreCastCodecs: ignoreSelectionCastCodecs
22762
+ })} from (${leftSelect}) ${sql.identifier("drizzle_union")}`;
22029
22763
  }
22030
22764
  buildSetOperationQuery({ leftSelect, setOperator: { type, isAll, rightSelect, limit, orderBy, offset } }) {
22031
22765
  const leftChunk = sql`(${leftSelect.getSQL()}) `;
22032
- const rightChunk = sql`(${rightSelect.getSQL()})`;
22766
+ const rightChunk = sql`(${rightSelect.withoutSelectionCastCodecs().getSQL()})`;
22033
22767
  let orderBySql;
22034
22768
  if (orderBy && orderBy.length > 0) {
22035
22769
  const orderByValues = [];
@@ -22055,8 +22789,9 @@ var PgDialect2 = class {
22055
22789
  buildInsertQuery({ table, values: valuesOrSelect, onConflict, returning, withList, select, overridingSystemValue_, comment, ignoreSelectionCastCodecs }) {
22056
22790
  const valuesSqlList = [];
22057
22791
  const columns = table[Table.Symbol.Columns];
22058
- const colEntries = Object.entries(columns).filter(([_, col]) => !col.shouldDisableInsert());
22059
- const insertOrder = colEntries.map(([, column]) => sql.identifier(column.name));
22792
+ const colEntries = Object.entries(columns);
22793
+ const colFilteredEntries = select && !is(valuesOrSelect, SQL) ? Object.keys(valuesOrSelect.getSelectedFields()).map((key) => [key, columns[key]]) : overridingSystemValue_ ? colEntries : colEntries.filter(([_, col]) => !col.shouldDisableInsert());
22794
+ const insertOrder = colFilteredEntries.map(([, column]) => sql.identifier(column.name));
22060
22795
  if (select) {
22061
22796
  const select2 = valuesOrSelect;
22062
22797
  if (is(select2, SQL))
@@ -22068,7 +22803,7 @@ var PgDialect2 = class {
22068
22803
  valuesSqlList.push(sql.raw("values "));
22069
22804
  for (const [valueIndex, value] of values.entries()) {
22070
22805
  const valueList = [];
22071
- for (const [fieldName, col] of colEntries) {
22806
+ for (const [fieldName, col] of colFilteredEntries) {
22072
22807
  const colValue = value[fieldName];
22073
22808
  if (colValue === undefined || is(colValue, Param) && colValue.value === undefined)
22074
22809
  if (col.defaultFn !== undefined) {
@@ -22119,31 +22854,48 @@ var PgDialect2 = class {
22119
22854
  tagged: true
22120
22855
  });
22121
22856
  }
22122
- nestedSelectionerror() {
22857
+ buildRqbColumn(table, field, key, inJson) {
22858
+ if (is(field, Column)) {
22859
+ const name2 = sql`${table}.${sql.identifier(field.name)}`;
22860
+ return sql`${inJson && field.jsonSelectIdentifier ? field.jsonSelectIdentifier(name2, sql, field.dimensions) : this.codecs.apply(field, inJson ? "castInJson" : "cast", name2)} as ${sql.identifier(key)}`;
22861
+ }
22862
+ if (is(field, SQL.Aliased)) {
22863
+ const column = getColumnFromDecoder2(field);
22864
+ const q = sql`${table}.${sql.identifier(field.fieldAlias)}`;
22865
+ return sql`${column ? this.codecs.apply(column, inJson ? "castInJson" : "cast", q) : q} as ${sql.identifier(key)}`;
22866
+ }
22867
+ if (isSQLWrapper(field)) {
22868
+ const column = getColumnFromDecoder2(field);
22869
+ const q = sql`${table}.${sql.identifier(key)}`;
22870
+ return sql`${column ? this.codecs.apply(column, inJson ? "castInJson" : "cast", q) : q} as ${sql.identifier(key)}`;
22871
+ }
22123
22872
  throw new DrizzleError2({ message: `Views with nested selections are not supported by the relational query builder` });
22124
22873
  }
22125
- buildRqbColumn(table, column, key, inJson) {
22126
- if (is(column, Column)) {
22127
- const name2 = sql`${table}.${sql.identifier(column.name)}`;
22128
- return sql`${inJson && column.jsonSelectIdentifier ? column.jsonSelectIdentifier(name2, sql, column.dimensions) : this.codecs.apply(column, inJson ? "castInJson" : "cast", name2)} as ${sql.identifier(key)}`;
22129
- }
22130
- return sql`${table}.${is(column, SQL.Aliased) ? sql.identifier(column.fieldAlias) : isSQLWrapper(column) ? sql.identifier(key) : this.nestedSelectionerror()} as ${sql.identifier(key)}`;
22874
+ resolveSelection(field, key, inJson) {
22875
+ if (is(field, Column))
22876
+ return {
22877
+ key,
22878
+ field,
22879
+ codec: this.codecs.get(field, inJson ? "normalizeInJson" : "normalize"),
22880
+ arrayDimensions: field.dimensions
22881
+ };
22882
+ const decoderColumn = getColumnFromDecoder2(field);
22883
+ return decoderColumn ? {
22884
+ key,
22885
+ field,
22886
+ codec: decoderColumn && (!inJson || !decoderColumn.mapFromJsonValue) ? this.codecs.get(decoderColumn, inJson ? "normalizeInJson" : "normalize") : undefined,
22887
+ arrayDimensions: decoderColumn.dimensions
22888
+ } : {
22889
+ key,
22890
+ field
22891
+ };
22131
22892
  }
22132
- unwrapAllColumns = (table, selection, inJson) => {
22133
- return sql.join(Object.entries(table[TableColumns]).map(([k, v2]) => {
22134
- selection.push(is(v2, Column) ? {
22135
- key: k,
22136
- codec: this.codecs.get(v2, inJson ? "normalizeInJson" : "normalize"),
22137
- arrayDimensions: v2.dimensions,
22138
- field: v2
22139
- } : {
22140
- key: k,
22141
- field: v2
22142
- });
22143
- return this.buildRqbColumn(table, v2, k, inJson);
22144
- }), sql`, `);
22145
- };
22146
- buildColumns = (table, selection, inJson, config) => config?.columns ? (() => {
22893
+ buildColumns = (table, selection, inJson, config) => {
22894
+ if (!config?.columns)
22895
+ return sql.join(Object.entries(table[TableColumns]).map(([k, v2]) => {
22896
+ selection.push(this.resolveSelection(v2, k, inJson));
22897
+ return this.buildRqbColumn(table, v2, k, inJson);
22898
+ }), sql`, `);
22147
22899
  const entries = Object.entries(config.columns);
22148
22900
  const columnContainer = table[TableColumns];
22149
22901
  const columnIdentifiers = [];
@@ -22155,15 +22907,7 @@ var PgDialect2 = class {
22155
22907
  if (v2) {
22156
22908
  const column = columnContainer[k];
22157
22909
  columnIdentifiers.push(this.buildRqbColumn(table, column, k, inJson));
22158
- selection.push(is(column, Column) ? {
22159
- key: k,
22160
- codec: this.codecs.get(column, inJson ? "normalizeInJson" : "normalize"),
22161
- arrayDimensions: column.dimensions,
22162
- field: column
22163
- } : {
22164
- key: k,
22165
- field: column
22166
- });
22910
+ selection.push(this.resolveSelection(column, k, inJson));
22167
22911
  }
22168
22912
  }
22169
22913
  if (colSelectionMode === false)
@@ -22171,18 +22915,10 @@ var PgDialect2 = class {
22171
22915
  if (config.columns[k] === false)
22172
22916
  continue;
22173
22917
  columnIdentifiers.push(this.buildRqbColumn(table, v2, k, inJson));
22174
- selection.push(is(v2, Column) ? {
22175
- key: k,
22176
- codec: this.codecs.get(v2, inJson ? "normalizeInJson" : "normalize"),
22177
- arrayDimensions: v2.dimensions,
22178
- field: v2
22179
- } : {
22180
- key: k,
22181
- field: v2
22182
- });
22918
+ selection.push(this.resolveSelection(v2, k, inJson));
22183
22919
  }
22184
22920
  return columnIdentifiers.length ? sql.join(columnIdentifiers, sql`, `) : undefined;
22185
- })() : this.unwrapAllColumns(table, selection, inJson);
22921
+ };
22186
22922
  buildRelationalQuery({ schema, table, tableConfig, queryConfig: config, relationWhere, mode, errorPath, depth, throughJoin, nested }) {
22187
22923
  const selection = [];
22188
22924
  const isSingle = mode === "first";
@@ -22196,7 +22932,7 @@ var PgDialect2 = class {
22196
22932
  const where = params?.where && relationWhere ? and(relationsFilterToSQL2(table, params.where, tableConfig.relations, schema), relationWhere) : params?.where ? relationsFilterToSQL2(table, params.where, tableConfig.relations, schema) : relationWhere;
22197
22933
  const order = params?.orderBy ? relationsOrderToSQL2(table, params.orderBy) : undefined;
22198
22934
  const columns = this.buildColumns(table, selection, !!nested, params);
22199
- const extras = params?.extras ? relationExtrasToSQL2(table, params.extras) : undefined;
22935
+ const extras = params?.extras ? relationExtrasToSQL2(table, params.extras, this.codecs, nested) : undefined;
22200
22936
  if (extras)
22201
22937
  selection.push(...extras.selection);
22202
22938
  const selectionArr = columns ? [columns] : [];
@@ -22346,11 +23082,6 @@ var PgInsertBuilder2 = class {
22346
23082
  this.overridingSystemValue_ = overridingSystemValue_;
22347
23083
  this.builder = builder;
22348
23084
  }
22349
- authToken;
22350
- setToken(token) {
22351
- this.authToken = token;
22352
- return this;
22353
- }
22354
23085
  overridingSystemValue() {
22355
23086
  this.overridingSystemValue_ = true;
22356
23087
  return this;
@@ -22368,27 +23099,25 @@ var PgInsertBuilder2 = class {
22368
23099
  }
22369
23100
  return result;
22370
23101
  });
22371
- const builder = new this.builder(this.table, mappedValues, this.session, this.dialect, this.withList, false, this.overridingSystemValue_);
22372
- if ("setToken" in builder)
22373
- builder.setToken(this.authToken);
22374
- return builder;
23102
+ return new this.builder(this.table, mappedValues, this.session, this.dialect, this.withList, false, this.overridingSystemValue_);
22375
23103
  }
22376
23104
  select(selectQuery) {
22377
23105
  const select = typeof selectQuery === "function" ? selectQuery(new QueryBuilder2) : selectQuery;
22378
23106
  if ("withoutSelectionCastCodecs" in select)
22379
23107
  select.withoutSelectionCastCodecs();
22380
- if (!is(select, SQL) && !haveSameKeys2(this.table[TableColumns], select._.selectedFields))
22381
- throw new Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");
22382
- const builder = new this.builder(this.table, select, this.session, this.dialect, this.withList, true);
22383
- if ("setToken" in builder)
22384
- builder.setToken(this.authToken);
22385
- return builder;
23108
+ if (!is(select, SQL)) {
23109
+ const insertCols = Object.keys(this.table[Table.Symbol.Columns]);
23110
+ const selected = Object.keys(select._.selectedFields);
23111
+ for (const col of selected)
23112
+ if (!insertCols.includes(col))
23113
+ throw new Error(`Insert select error: column "${col}" does not exist in table "${this.table[Table.Symbol.Name]}"`);
23114
+ }
23115
+ return new this.builder(this.table, select, this.session, this.dialect, this.withList, true, this.overridingSystemValue_);
22386
23116
  }
22387
23117
  };
22388
23118
  var PgInsertBase2 = class {
22389
23119
  static [entityKind] = "PgInsert";
22390
23120
  config;
22391
- cacheConfig;
22392
23121
  constructor(table, values, session, dialect, withList, select, overridingSystemValue_) {
22393
23122
  this.session = session;
22394
23123
  this.dialect = dialect;
@@ -22458,7 +23187,7 @@ var PgInsertBase2 = class {
22458
23187
  var PgAsyncInsertBase2 = class extends PgInsertBase2 {
22459
23188
  static [entityKind] = "PgAsyncInsert";
22460
23189
  _prepare(name2, generateName = false) {
22461
- const { session, config, dialect, cacheConfig } = this;
23190
+ const { session, config, dialect } = this;
22462
23191
  const { returning: fields } = config;
22463
23192
  return tracer.startActiveSpan("drizzle.prepareQuery", () => {
22464
23193
  const query = dialect.sqlToQuery(this.getSQL());
@@ -22466,7 +23195,7 @@ var PgAsyncInsertBase2 = class extends PgInsertBase2 {
22466
23195
  return session.prepareQuery(query, fields ? "arrays" : "raw", name2 ?? generateName, mapper, {
22467
23196
  type: "insert",
22468
23197
  tables: [...extractUsedTable(this.config.table)]
22469
- }, cacheConfig);
23198
+ });
22470
23199
  });
22471
23200
  }
22472
23201
  prepare(name2) {
@@ -22511,10 +23240,10 @@ applyMixins2(PgAsyncRelationalQuery2, [QueryPromise2]);
22511
23240
  // node_modules/drizzle-orm/pg-core/query-builders/raw.js
22512
23241
  var PgRaw = class {
22513
23242
  static [entityKind] = "PgRaw";
22514
- constructor(sql2, query, mapBatchResult) {
23243
+ constructor(prepared, sql2, query) {
23244
+ this.prepared = prepared;
22515
23245
  this.sql = sql2;
22516
23246
  this.query = query;
22517
- this.mapBatchResult = mapBatchResult;
22518
23247
  }
22519
23248
  getSQL() {
22520
23249
  return this.sql;
@@ -22522,20 +23251,22 @@ var PgRaw = class {
22522
23251
  getQuery() {
22523
23252
  return this.query;
22524
23253
  }
22525
- mapResult(result, isFromBatch) {
22526
- return isFromBatch ? this.mapBatchResult(result) : result;
23254
+ _prepare() {
23255
+ return this.prepared;
22527
23256
  }
22528
23257
  };
22529
23258
 
22530
23259
  // node_modules/drizzle-orm/pg-core/async/raw.js
22531
23260
  var PgAsyncRaw2 = class extends PgRaw {
22532
23261
  static [entityKind] = "PgAsyncRaw";
22533
- constructor(execute, sql2, query, mapBatchResult) {
22534
- super(sql2, query, mapBatchResult);
22535
- this.execute = execute;
23262
+ constructor(prepared, sql2, query) {
23263
+ super(prepared, sql2, query);
23264
+ }
23265
+ execute(placeholderValues) {
23266
+ return this.prepared.execute(placeholderValues);
22536
23267
  }
22537
23268
  _prepare() {
22538
- return this;
23269
+ return this.prepared;
22539
23270
  }
22540
23271
  };
22541
23272
  applyMixins2(PgAsyncRaw2, [QueryPromise2]);
@@ -22593,12 +23324,11 @@ applyMixins2(PgAsyncRefreshMaterializedView2, [QueryPromise2]);
22593
23324
  var PgAsyncSelectBase2 = class extends PgSelectBase2 {
22594
23325
  static [entityKind] = "PgAsyncSelectQueryBuilder";
22595
23326
  _prepare(name2, generateName = false) {
22596
- const { session, config, dialect, joinsNotNullableMap, cacheConfig, usedTables } = this;
22597
- const { fields } = config;
23327
+ const { session, dialect, cacheConfig, usedTables } = this;
22598
23328
  return tracer.startActiveSpan("drizzle.prepareQuery", () => {
22599
- const query = this.config._tagged ? dialect._sqlToQuery(this.getSQL()) : dialect.sqlToQuery(this.getSQL());
22600
- const fieldsList = orderSelectedFields2(fields, undefined, this.dialect.codecs);
22601
- const mapper = this.dialect.mapperGenerators.rows(fieldsList, joinsNotNullableMap);
23329
+ const query = this.config.tagged ? dialect._sqlToQuery(this.getSQL()) : dialect.sqlToQuery(this.getSQL());
23330
+ const fieldsList = this.config.fieldsFlat;
23331
+ const mapper = this.dialect.mapperGenerators.rows(fieldsList, this.joinsNotNullableMap);
22602
23332
  return session.prepareQuery(query, "arrays", name2 ?? generateName, mapper, {
22603
23333
  type: "select",
22604
23334
  tables: [...usedTables]
@@ -22626,16 +23356,8 @@ var PgUpdateBuilder2 = class {
22626
23356
  this.withList = withList;
22627
23357
  this.builder = builder;
22628
23358
  }
22629
- authToken;
22630
- setToken(token) {
22631
- this.authToken = token;
22632
- return this;
22633
- }
22634
23359
  set(values) {
22635
- const builder = new this.builder(this.table, mapUpdateSet2(this.table, values), this.session, this.dialect, this.withList);
22636
- if ("setToken" in builder)
22637
- builder.setToken(this.authToken);
22638
- return builder;
23360
+ return new this.builder(this.table, mapUpdateSet2(this.table, values), this.session, this.dialect, this.withList);
22639
23361
  }
22640
23362
  };
22641
23363
  var PgUpdateBase2 = class {
@@ -22643,7 +23365,6 @@ var PgUpdateBase2 = class {
22643
23365
  config;
22644
23366
  tableName;
22645
23367
  joinsNotNullableMap;
22646
- cacheConfig;
22647
23368
  constructor(table, set, session, dialect, withList) {
22648
23369
  this.session = session;
22649
23370
  this.dialect = dialect;
@@ -22772,7 +23493,7 @@ var PgUpdateBase2 = class {
22772
23493
  var PgAsyncUpdateBase2 = class extends PgUpdateBase2 {
22773
23494
  static [entityKind] = "PgAsyncUpdate";
22774
23495
  _prepare(name2, generateName = false) {
22775
- const { session, config, dialect, joinsNotNullableMap, cacheConfig } = this;
23496
+ const { session, config, dialect, joinsNotNullableMap } = this;
22776
23497
  const { returning: fields } = config;
22777
23498
  return tracer.startActiveSpan("drizzle.prepareQuery", () => {
22778
23499
  const query = dialect.sqlToQuery(this.getSQL());
@@ -22780,7 +23501,7 @@ var PgAsyncUpdateBase2 = class extends PgUpdateBase2 {
22780
23501
  return session.prepareQuery(query, fields ? "arrays" : "raw", name2 ?? generateName, mapper, {
22781
23502
  type: "update",
22782
23503
  tables: [...extractUsedTable(this.config.table)]
22783
- }, cacheConfig);
23504
+ });
22784
23505
  });
22785
23506
  }
22786
23507
  prepare(name2) {
@@ -22920,8 +23641,7 @@ var PgAsyncDatabase2 = class {
22920
23641
  execute(query) {
22921
23642
  const sequel = typeof query === "string" ? sql.raw(query) : query.getSQL();
22922
23643
  const builtQuery = this.dialect.sqlToQuery(sequel);
22923
- const prepared = this.session.prepareQuery(builtQuery, "raw", false);
22924
- return new PgAsyncRaw2(() => prepared.execute(), sequel, builtQuery, (result) => prepared.mapResult(result, true));
23644
+ return new PgAsyncRaw2(this.session.prepareQuery(builtQuery, "raw", false), sequel, builtQuery);
22925
23645
  }
22926
23646
  transaction(transaction, config) {
22927
23647
  return this.session.transaction(transaction, config);
@@ -22934,9 +23654,6 @@ var PgBasePreparedQuery2 = class {
22934
23654
  constructor(query) {
22935
23655
  this.query = query;
22936
23656
  }
22937
- mapResult(_, __) {
22938
- throw new Error("Method not implemented.");
22939
- }
22940
23657
  getQuery() {
22941
23658
  return this.query;
22942
23659
  }
@@ -26463,23 +27180,28 @@ var createInMemoryAgentRegistrationStore = () => {
26463
27180
  var ID_LENGTH7 = 255;
26464
27181
  var NAME_LENGTH = 255;
26465
27182
  var STATUS_LENGTH2 = 16;
27183
+ var portableJsonb = customType({
27184
+ dataType: () => "jsonb",
27185
+ fromDriver: (value) => typeof value === "string" ? JSON.parse(value) : value,
27186
+ toDriver: (value) => JSON.stringify(value)
27187
+ });
26466
27188
  var agentDelegationsTable = pgTable("auth_agent_delegations", {
26467
27189
  agent_id: varchar("agent_id", { length: ID_LENGTH7 }).notNull(),
26468
- authorization_details: jsonb("authorization_details").$type(),
27190
+ authorization_details: portableJsonb("authorization_details").$type(),
26469
27191
  created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
26470
27192
  delegation_id: varchar("delegation_id", {
26471
27193
  length: ID_LENGTH7
26472
27194
  }).primaryKey(),
26473
27195
  expires_at_ms: bigint("expires_at_ms", { mode: "number" }),
26474
27196
  organization_id: varchar("organization_id", { length: ID_LENGTH7 }),
26475
- scopes: jsonb("scopes").$type().notNull().default([]),
27197
+ scopes: portableJsonb("scopes").$type().notNull().default([]),
26476
27198
  status: varchar("status", { length: STATUS_LENGTH2 }).$type().notNull(),
26477
27199
  updated_at_ms: bigint("updated_at_ms", { mode: "number" }).notNull(),
26478
27200
  user_id: varchar("user_id", { length: ID_LENGTH7 }).notNull()
26479
27201
  });
26480
27202
  var agentIdentityRegistrationsTable = pgTable("auth_agent_identity_registrations", {
26481
27203
  agent_id: varchar("agent_id", { length: ID_LENGTH7 }).notNull().unique(),
26482
- claim_attempt: jsonb("claim_attempt").$type(),
27204
+ claim_attempt: portableJsonb("claim_attempt").$type(),
26483
27205
  claim_attempt_token_hash: varchar("claim_attempt_token_hash", {
26484
27206
  length: ID_LENGTH7
26485
27207
  }).unique(),
@@ -26511,10 +27233,10 @@ var agentIdentityRegistrationsTable = pgTable("auth_agent_identity_registrations
26511
27233
  ]);
26512
27234
  var agentRegistrationsTable = pgTable("auth_agent_registrations", {
26513
27235
  agent_id: varchar("agent_id", { length: ID_LENGTH7 }).primaryKey(),
26514
- allowed_scopes: jsonb("allowed_scopes").$type().notNull().default([]),
27236
+ allowed_scopes: portableJsonb("allowed_scopes").$type().notNull().default([]),
26515
27237
  client_id: varchar("client_id", { length: ID_LENGTH7 }).unique(),
26516
27238
  created_at_ms: bigint("created_at_ms", { mode: "number" }).notNull(),
26517
- metadata: jsonb("metadata").$type(),
27239
+ metadata: portableJsonb("metadata").$type(),
26518
27240
  name: varchar("name", { length: NAME_LENGTH }).notNull(),
26519
27241
  status: varchar("status", { length: STATUS_LENGTH2 }).$type().notNull(),
26520
27242
  updated_at_ms: bigint("updated_at_ms", { mode: "number" }).notNull()
@@ -29804,5 +30526,5 @@ export {
29804
30526
  auth2 as auth
29805
30527
  };
29806
30528
 
29807
- //# debugId=059E7E401823BC2864756E2164756E21
30529
+ //# debugId=93AC61559A0D9C9764756E2164756E21
29808
30530
  //# sourceMappingURL=server.js.map