drizzle-kit 1.0.0-beta.1-ec0aae1 → 1.0.0-beta.1-6b935a0
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/api.js +146 -5
- package/api.mjs +146 -5
- package/bin.cjs +1 -1
- package/package.json +1 -1
package/api.js
CHANGED
@@ -22282,6 +22282,14 @@ var init_common2 = __esm({
|
|
22282
22282
|
}
|
22283
22283
|
return value.map((v) => this.baseColumn.mapFromDriverValue(v));
|
22284
22284
|
}
|
22285
|
+
// Needed for arrays of custom types
|
22286
|
+
mapFromJsonValue(value) {
|
22287
|
+
if (typeof value === "string") {
|
22288
|
+
value = parsePgArray(value);
|
22289
|
+
}
|
22290
|
+
const base = this.baseColumn;
|
22291
|
+
return "mapFromJsonValue" in base ? value.map((v) => base.mapFromJsonValue(v)) : value.map((v) => base.mapFromDriverValue(v));
|
22292
|
+
}
|
22285
22293
|
mapToDriverValue(value, isNestedArray = false) {
|
22286
22294
|
const a = value.map(
|
22287
22295
|
(v) => v === null ? null : is(this.baseColumn, _PgArray) ? this.baseColumn.mapToDriverValue(v, true) : this.baseColumn.mapToDriverValue(v)
|
@@ -23403,7 +23411,7 @@ function mapRelationalRow(row, buildQueryResultSelection, mapColumnValue = (valu
|
|
23403
23411
|
} else {
|
23404
23412
|
decoder = field.getSQL().decoder;
|
23405
23413
|
}
|
23406
|
-
row[selectionItem.key] = decoder.mapFromDriverValue(value);
|
23414
|
+
row[selectionItem.key] = "mapFromJsonValue" in decoder ? decoder.mapFromJsonValue(value) : decoder.mapFromDriverValue(value);
|
23407
23415
|
}
|
23408
23416
|
return row;
|
23409
23417
|
}
|
@@ -23945,6 +23953,9 @@ Hint: you can specify "alias" on both sides of the relation with the same value`
|
|
23945
23953
|
gte,
|
23946
23954
|
ilike,
|
23947
23955
|
inArray,
|
23956
|
+
arrayContains,
|
23957
|
+
arrayContained,
|
23958
|
+
arrayOverlaps,
|
23948
23959
|
isNull,
|
23949
23960
|
isNotNull,
|
23950
23961
|
like,
|
@@ -24733,6 +24744,15 @@ var init_bytea = __esm({
|
|
24733
24744
|
};
|
24734
24745
|
__publicField(PgByteaBuilder, _a58, "PgByteaBuilder");
|
24735
24746
|
PgBytea = class extends (_b29 = PgColumn, _a59 = entityKind, _b29) {
|
24747
|
+
mapFromDriverValue(value) {
|
24748
|
+
if (Buffer.isBuffer(value))
|
24749
|
+
return value;
|
24750
|
+
if (typeof value === "string") {
|
24751
|
+
const trimmed = value.slice(2, value.length);
|
24752
|
+
return Buffer.from(trimmed, "hex");
|
24753
|
+
}
|
24754
|
+
return Buffer.from(value);
|
24755
|
+
}
|
24736
24756
|
getSQLType() {
|
24737
24757
|
return "bytea";
|
24738
24758
|
}
|
@@ -24846,9 +24866,13 @@ var init_custom = __esm({
|
|
24846
24866
|
__publicField(this, "sqlName");
|
24847
24867
|
__publicField(this, "mapTo");
|
24848
24868
|
__publicField(this, "mapFrom");
|
24869
|
+
__publicField(this, "mapJson");
|
24870
|
+
__publicField(this, "wrapName");
|
24849
24871
|
this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
|
24850
24872
|
this.mapTo = config.customTypeParams.toDriver;
|
24851
24873
|
this.mapFrom = config.customTypeParams.fromDriver;
|
24874
|
+
this.mapJson = config.customTypeParams.fromJson;
|
24875
|
+
this.wrapName = config.customTypeParams.jsonWrap;
|
24852
24876
|
}
|
24853
24877
|
getSQLType() {
|
24854
24878
|
return this.sqlName;
|
@@ -24856,6 +24880,29 @@ var init_custom = __esm({
|
|
24856
24880
|
mapFromDriverValue(value) {
|
24857
24881
|
return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
|
24858
24882
|
}
|
24883
|
+
mapFromJsonValue(value) {
|
24884
|
+
return typeof this.mapJson === "function" ? this.mapJson(value) : this.mapFromDriverValue(value);
|
24885
|
+
}
|
24886
|
+
jsonWrapName(name2, sql2, arrayDimensions) {
|
24887
|
+
if (typeof this.wrapName === "function")
|
24888
|
+
return this.wrapName(name2, sql2, arrayDimensions);
|
24889
|
+
const rawType = this.getSQLType().toLowerCase();
|
24890
|
+
const parenPos = rawType.indexOf("(");
|
24891
|
+
const type = parenPos + 1 ? rawType.slice(0, parenPos) : rawType;
|
24892
|
+
switch (type) {
|
24893
|
+
case "bytea":
|
24894
|
+
case "geometry":
|
24895
|
+
case "timestamp":
|
24896
|
+
case "numeric":
|
24897
|
+
case "bigint": {
|
24898
|
+
const arrVal = "[]".repeat(arrayDimensions ?? 0);
|
24899
|
+
return sql2`${name2}::text${sql2.raw(arrVal).if(arrayDimensions)}`;
|
24900
|
+
}
|
24901
|
+
default: {
|
24902
|
+
return name2;
|
24903
|
+
}
|
24904
|
+
}
|
24905
|
+
}
|
24859
24906
|
mapToDriverValue(value) {
|
24860
24907
|
return typeof this.mapTo === "function" ? this.mapTo(value) : value;
|
24861
24908
|
}
|
@@ -27538,11 +27585,11 @@ var init_dialect = __esm({
|
|
27538
27585
|
const name2 = sql`${table6}.${sql.identifier(this.casing.getColumnCasing(column6))}`;
|
27539
27586
|
let targetType = column6.columnType;
|
27540
27587
|
let col = column6;
|
27541
|
-
let
|
27588
|
+
let dimensionCnt = 0;
|
27542
27589
|
while (is(col, PgArray)) {
|
27543
|
-
col =
|
27590
|
+
col = col.baseColumn;
|
27544
27591
|
targetType = col.columnType;
|
27545
|
-
|
27592
|
+
++dimensionCnt;
|
27546
27593
|
}
|
27547
27594
|
switch (targetType) {
|
27548
27595
|
case "PgNumeric":
|
@@ -27552,9 +27599,14 @@ var init_dialect = __esm({
|
|
27552
27599
|
case "PgBigSerial64":
|
27553
27600
|
case "PgTimestampString":
|
27554
27601
|
case "PgGeometry":
|
27555
|
-
case "PgGeometryObject":
|
27602
|
+
case "PgGeometryObject":
|
27603
|
+
case "PgBytea": {
|
27604
|
+
const arrVal = "[]".repeat(dimensionCnt);
|
27556
27605
|
return sql`${name2}::text${sql.raw(arrVal).if(arrVal)} as ${sql.identifier(key)}`;
|
27557
27606
|
}
|
27607
|
+
case "PgCustomColumn": {
|
27608
|
+
return sql`${col.jsonWrapName(name2, sql, dimensionCnt > 0 ? dimensionCnt : void 0)} as ${sql.identifier(key)}`;
|
27609
|
+
}
|
27558
27610
|
default: {
|
27559
27611
|
return sql`${name2} as ${sql.identifier(key)}`;
|
27560
27612
|
}
|
@@ -32518,9 +32570,13 @@ var init_custom2 = __esm({
|
|
32518
32570
|
__publicField(this, "sqlName");
|
32519
32571
|
__publicField(this, "mapTo");
|
32520
32572
|
__publicField(this, "mapFrom");
|
32573
|
+
__publicField(this, "mapJson");
|
32574
|
+
__publicField(this, "wrapName");
|
32521
32575
|
this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
|
32522
32576
|
this.mapTo = config.customTypeParams.toDriver;
|
32523
32577
|
this.mapFrom = config.customTypeParams.fromDriver;
|
32578
|
+
this.mapJson = config.customTypeParams.fromJson;
|
32579
|
+
this.wrapName = config.customTypeParams.jsonWrap;
|
32524
32580
|
}
|
32525
32581
|
getSQLType() {
|
32526
32582
|
return this.sqlName;
|
@@ -32528,6 +32584,29 @@ var init_custom2 = __esm({
|
|
32528
32584
|
mapFromDriverValue(value) {
|
32529
32585
|
return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
|
32530
32586
|
}
|
32587
|
+
mapFromJsonValue(value) {
|
32588
|
+
return typeof this.mapJson === "function" ? this.mapJson(value) : this.mapFromDriverValue(value);
|
32589
|
+
}
|
32590
|
+
jsonWrapName(name2, sql2) {
|
32591
|
+
if (typeof this.wrapName === "function")
|
32592
|
+
return this.wrapName(name2, sql2);
|
32593
|
+
const rawType = this.getSQLType().toLowerCase();
|
32594
|
+
const parenPos = rawType.indexOf("(");
|
32595
|
+
const type = parenPos + 1 ? rawType.slice(0, parenPos) : rawType;
|
32596
|
+
switch (type) {
|
32597
|
+
case "numeric":
|
32598
|
+
case "decimal":
|
32599
|
+
case "bigint": {
|
32600
|
+
return sql2`cast(${name2} as text)`;
|
32601
|
+
}
|
32602
|
+
case "blob": {
|
32603
|
+
return sql2`hex(${name2})`;
|
32604
|
+
}
|
32605
|
+
default: {
|
32606
|
+
return name2;
|
32607
|
+
}
|
32608
|
+
}
|
32609
|
+
}
|
32531
32610
|
mapToDriverValue(value) {
|
32532
32611
|
return typeof this.mapTo === "function" ? this.mapTo(value) : value;
|
32533
32612
|
}
|
@@ -33721,6 +33800,9 @@ var init_dialect2 = __esm({
|
|
33721
33800
|
case "SQLiteNumericBigInt": {
|
33722
33801
|
return sql`cast(${name2} as text) as ${sql.identifier(key)}`;
|
33723
33802
|
}
|
33803
|
+
case "SQLiteCustomColumn": {
|
33804
|
+
return sql`${column6.jsonWrapName(name2, sql)} as ${sql.identifier(key)}`;
|
33805
|
+
}
|
33724
33806
|
default: {
|
33725
33807
|
return sql`${name2} as ${sql.identifier(key)}`;
|
33726
33808
|
}
|
@@ -37330,9 +37412,13 @@ var init_custom3 = __esm({
|
|
37330
37412
|
__publicField(this, "sqlName");
|
37331
37413
|
__publicField(this, "mapTo");
|
37332
37414
|
__publicField(this, "mapFrom");
|
37415
|
+
__publicField(this, "mapJson");
|
37416
|
+
__publicField(this, "wrapName");
|
37333
37417
|
this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
|
37334
37418
|
this.mapTo = config.customTypeParams.toDriver;
|
37335
37419
|
this.mapFrom = config.customTypeParams.fromDriver;
|
37420
|
+
this.mapJson = config.customTypeParams.fromJson;
|
37421
|
+
this.wrapName = config.customTypeParams.jsonWrap;
|
37336
37422
|
}
|
37337
37423
|
getSQLType() {
|
37338
37424
|
return this.sqlName;
|
@@ -37340,6 +37426,30 @@ var init_custom3 = __esm({
|
|
37340
37426
|
mapFromDriverValue(value) {
|
37341
37427
|
return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
|
37342
37428
|
}
|
37429
|
+
mapFromJsonValue(value) {
|
37430
|
+
return typeof this.mapJson === "function" ? this.mapJson(value) : this.mapFromDriverValue(value);
|
37431
|
+
}
|
37432
|
+
jsonWrapName(name2, sql2) {
|
37433
|
+
if (typeof this.wrapName === "function")
|
37434
|
+
return this.wrapName(name2, sql2);
|
37435
|
+
const rawType = this.getSQLType().toLowerCase();
|
37436
|
+
const parenPos = rawType.indexOf("(");
|
37437
|
+
const type = parenPos + 1 ? rawType.slice(0, parenPos) : rawType;
|
37438
|
+
switch (type) {
|
37439
|
+
case "binary":
|
37440
|
+
case "varbinary":
|
37441
|
+
case "time":
|
37442
|
+
case "datetime":
|
37443
|
+
case "decimal":
|
37444
|
+
case "float":
|
37445
|
+
case "bigint": {
|
37446
|
+
return sql2`cast(${name2} as char)`;
|
37447
|
+
}
|
37448
|
+
default: {
|
37449
|
+
return name2;
|
37450
|
+
}
|
37451
|
+
}
|
37452
|
+
}
|
37343
37453
|
mapToDriverValue(value) {
|
37344
37454
|
return typeof this.mapTo === "function" ? this.mapTo(value) : value;
|
37345
37455
|
}
|
@@ -39698,6 +39808,9 @@ var init_dialect3 = __esm({
|
|
39698
39808
|
case "MySqlBigInt64": {
|
39699
39809
|
return sql`cast(${name2} as char) as ${sql.identifier(key)}`;
|
39700
39810
|
}
|
39811
|
+
case "MySqlCustomColumn": {
|
39812
|
+
return sql`${column6.jsonWrapName(name2, sql)} as ${sql.identifier(key)}`;
|
39813
|
+
}
|
39701
39814
|
default: {
|
39702
39815
|
return sql`${name2} as ${sql.identifier(key)}`;
|
39703
39816
|
}
|
@@ -43300,9 +43413,13 @@ var init_custom4 = __esm({
|
|
43300
43413
|
__publicField(this, "sqlName");
|
43301
43414
|
__publicField(this, "mapTo");
|
43302
43415
|
__publicField(this, "mapFrom");
|
43416
|
+
__publicField(this, "mapJson");
|
43417
|
+
__publicField(this, "wrapName");
|
43303
43418
|
this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
|
43304
43419
|
this.mapTo = config.customTypeParams.toDriver;
|
43305
43420
|
this.mapFrom = config.customTypeParams.fromDriver;
|
43421
|
+
this.mapJson = config.customTypeParams.fromJson;
|
43422
|
+
this.wrapName = config.customTypeParams.jsonWrap;
|
43306
43423
|
}
|
43307
43424
|
getSQLType() {
|
43308
43425
|
return this.sqlName;
|
@@ -43310,6 +43427,30 @@ var init_custom4 = __esm({
|
|
43310
43427
|
mapFromDriverValue(value) {
|
43311
43428
|
return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
|
43312
43429
|
}
|
43430
|
+
mapFromJsonValue(value) {
|
43431
|
+
return typeof this.mapJson === "function" ? this.mapJson(value) : this.mapFromDriverValue(value);
|
43432
|
+
}
|
43433
|
+
jsonWrapName(name2, sql2) {
|
43434
|
+
if (typeof this.wrapName === "function")
|
43435
|
+
return this.wrapName(name2, sql2);
|
43436
|
+
const rawType = this.getSQLType().toLowerCase();
|
43437
|
+
const parenPos = rawType.indexOf("(");
|
43438
|
+
const type = parenPos + 1 ? rawType.slice(0, parenPos) : rawType;
|
43439
|
+
switch (type) {
|
43440
|
+
case "binary":
|
43441
|
+
case "varbinary":
|
43442
|
+
case "time":
|
43443
|
+
case "datetime":
|
43444
|
+
case "decimal":
|
43445
|
+
case "float":
|
43446
|
+
case "bigint": {
|
43447
|
+
return sql2`cast(${name2} as char)`;
|
43448
|
+
}
|
43449
|
+
default: {
|
43450
|
+
return name2;
|
43451
|
+
}
|
43452
|
+
}
|
43453
|
+
}
|
43313
43454
|
mapToDriverValue(value) {
|
43314
43455
|
return typeof this.mapTo === "function" ? this.mapTo(value) : value;
|
43315
43456
|
}
|
package/api.mjs
CHANGED
@@ -22287,6 +22287,14 @@ var init_common2 = __esm({
|
|
22287
22287
|
}
|
22288
22288
|
return value.map((v) => this.baseColumn.mapFromDriverValue(v));
|
22289
22289
|
}
|
22290
|
+
// Needed for arrays of custom types
|
22291
|
+
mapFromJsonValue(value) {
|
22292
|
+
if (typeof value === "string") {
|
22293
|
+
value = parsePgArray(value);
|
22294
|
+
}
|
22295
|
+
const base = this.baseColumn;
|
22296
|
+
return "mapFromJsonValue" in base ? value.map((v) => base.mapFromJsonValue(v)) : value.map((v) => base.mapFromDriverValue(v));
|
22297
|
+
}
|
22290
22298
|
mapToDriverValue(value, isNestedArray = false) {
|
22291
22299
|
const a = value.map(
|
22292
22300
|
(v) => v === null ? null : is(this.baseColumn, _PgArray) ? this.baseColumn.mapToDriverValue(v, true) : this.baseColumn.mapToDriverValue(v)
|
@@ -23408,7 +23416,7 @@ function mapRelationalRow(row, buildQueryResultSelection, mapColumnValue = (valu
|
|
23408
23416
|
} else {
|
23409
23417
|
decoder = field.getSQL().decoder;
|
23410
23418
|
}
|
23411
|
-
row[selectionItem.key] = decoder.mapFromDriverValue(value);
|
23419
|
+
row[selectionItem.key] = "mapFromJsonValue" in decoder ? decoder.mapFromJsonValue(value) : decoder.mapFromDriverValue(value);
|
23412
23420
|
}
|
23413
23421
|
return row;
|
23414
23422
|
}
|
@@ -23950,6 +23958,9 @@ Hint: you can specify "alias" on both sides of the relation with the same value`
|
|
23950
23958
|
gte,
|
23951
23959
|
ilike,
|
23952
23960
|
inArray,
|
23961
|
+
arrayContains,
|
23962
|
+
arrayContained,
|
23963
|
+
arrayOverlaps,
|
23953
23964
|
isNull,
|
23954
23965
|
isNotNull,
|
23955
23966
|
like,
|
@@ -24738,6 +24749,15 @@ var init_bytea = __esm({
|
|
24738
24749
|
};
|
24739
24750
|
__publicField(PgByteaBuilder, _a58, "PgByteaBuilder");
|
24740
24751
|
PgBytea = class extends (_b29 = PgColumn, _a59 = entityKind, _b29) {
|
24752
|
+
mapFromDriverValue(value) {
|
24753
|
+
if (Buffer.isBuffer(value))
|
24754
|
+
return value;
|
24755
|
+
if (typeof value === "string") {
|
24756
|
+
const trimmed = value.slice(2, value.length);
|
24757
|
+
return Buffer.from(trimmed, "hex");
|
24758
|
+
}
|
24759
|
+
return Buffer.from(value);
|
24760
|
+
}
|
24741
24761
|
getSQLType() {
|
24742
24762
|
return "bytea";
|
24743
24763
|
}
|
@@ -24851,9 +24871,13 @@ var init_custom = __esm({
|
|
24851
24871
|
__publicField(this, "sqlName");
|
24852
24872
|
__publicField(this, "mapTo");
|
24853
24873
|
__publicField(this, "mapFrom");
|
24874
|
+
__publicField(this, "mapJson");
|
24875
|
+
__publicField(this, "wrapName");
|
24854
24876
|
this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
|
24855
24877
|
this.mapTo = config.customTypeParams.toDriver;
|
24856
24878
|
this.mapFrom = config.customTypeParams.fromDriver;
|
24879
|
+
this.mapJson = config.customTypeParams.fromJson;
|
24880
|
+
this.wrapName = config.customTypeParams.jsonWrap;
|
24857
24881
|
}
|
24858
24882
|
getSQLType() {
|
24859
24883
|
return this.sqlName;
|
@@ -24861,6 +24885,29 @@ var init_custom = __esm({
|
|
24861
24885
|
mapFromDriverValue(value) {
|
24862
24886
|
return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
|
24863
24887
|
}
|
24888
|
+
mapFromJsonValue(value) {
|
24889
|
+
return typeof this.mapJson === "function" ? this.mapJson(value) : this.mapFromDriverValue(value);
|
24890
|
+
}
|
24891
|
+
jsonWrapName(name2, sql2, arrayDimensions) {
|
24892
|
+
if (typeof this.wrapName === "function")
|
24893
|
+
return this.wrapName(name2, sql2, arrayDimensions);
|
24894
|
+
const rawType = this.getSQLType().toLowerCase();
|
24895
|
+
const parenPos = rawType.indexOf("(");
|
24896
|
+
const type = parenPos + 1 ? rawType.slice(0, parenPos) : rawType;
|
24897
|
+
switch (type) {
|
24898
|
+
case "bytea":
|
24899
|
+
case "geometry":
|
24900
|
+
case "timestamp":
|
24901
|
+
case "numeric":
|
24902
|
+
case "bigint": {
|
24903
|
+
const arrVal = "[]".repeat(arrayDimensions ?? 0);
|
24904
|
+
return sql2`${name2}::text${sql2.raw(arrVal).if(arrayDimensions)}`;
|
24905
|
+
}
|
24906
|
+
default: {
|
24907
|
+
return name2;
|
24908
|
+
}
|
24909
|
+
}
|
24910
|
+
}
|
24864
24911
|
mapToDriverValue(value) {
|
24865
24912
|
return typeof this.mapTo === "function" ? this.mapTo(value) : value;
|
24866
24913
|
}
|
@@ -27543,11 +27590,11 @@ var init_dialect = __esm({
|
|
27543
27590
|
const name2 = sql`${table6}.${sql.identifier(this.casing.getColumnCasing(column6))}`;
|
27544
27591
|
let targetType = column6.columnType;
|
27545
27592
|
let col = column6;
|
27546
|
-
let
|
27593
|
+
let dimensionCnt = 0;
|
27547
27594
|
while (is(col, PgArray)) {
|
27548
|
-
col =
|
27595
|
+
col = col.baseColumn;
|
27549
27596
|
targetType = col.columnType;
|
27550
|
-
|
27597
|
+
++dimensionCnt;
|
27551
27598
|
}
|
27552
27599
|
switch (targetType) {
|
27553
27600
|
case "PgNumeric":
|
@@ -27557,9 +27604,14 @@ var init_dialect = __esm({
|
|
27557
27604
|
case "PgBigSerial64":
|
27558
27605
|
case "PgTimestampString":
|
27559
27606
|
case "PgGeometry":
|
27560
|
-
case "PgGeometryObject":
|
27607
|
+
case "PgGeometryObject":
|
27608
|
+
case "PgBytea": {
|
27609
|
+
const arrVal = "[]".repeat(dimensionCnt);
|
27561
27610
|
return sql`${name2}::text${sql.raw(arrVal).if(arrVal)} as ${sql.identifier(key)}`;
|
27562
27611
|
}
|
27612
|
+
case "PgCustomColumn": {
|
27613
|
+
return sql`${col.jsonWrapName(name2, sql, dimensionCnt > 0 ? dimensionCnt : void 0)} as ${sql.identifier(key)}`;
|
27614
|
+
}
|
27563
27615
|
default: {
|
27564
27616
|
return sql`${name2} as ${sql.identifier(key)}`;
|
27565
27617
|
}
|
@@ -32523,9 +32575,13 @@ var init_custom2 = __esm({
|
|
32523
32575
|
__publicField(this, "sqlName");
|
32524
32576
|
__publicField(this, "mapTo");
|
32525
32577
|
__publicField(this, "mapFrom");
|
32578
|
+
__publicField(this, "mapJson");
|
32579
|
+
__publicField(this, "wrapName");
|
32526
32580
|
this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
|
32527
32581
|
this.mapTo = config.customTypeParams.toDriver;
|
32528
32582
|
this.mapFrom = config.customTypeParams.fromDriver;
|
32583
|
+
this.mapJson = config.customTypeParams.fromJson;
|
32584
|
+
this.wrapName = config.customTypeParams.jsonWrap;
|
32529
32585
|
}
|
32530
32586
|
getSQLType() {
|
32531
32587
|
return this.sqlName;
|
@@ -32533,6 +32589,29 @@ var init_custom2 = __esm({
|
|
32533
32589
|
mapFromDriverValue(value) {
|
32534
32590
|
return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
|
32535
32591
|
}
|
32592
|
+
mapFromJsonValue(value) {
|
32593
|
+
return typeof this.mapJson === "function" ? this.mapJson(value) : this.mapFromDriverValue(value);
|
32594
|
+
}
|
32595
|
+
jsonWrapName(name2, sql2) {
|
32596
|
+
if (typeof this.wrapName === "function")
|
32597
|
+
return this.wrapName(name2, sql2);
|
32598
|
+
const rawType = this.getSQLType().toLowerCase();
|
32599
|
+
const parenPos = rawType.indexOf("(");
|
32600
|
+
const type = parenPos + 1 ? rawType.slice(0, parenPos) : rawType;
|
32601
|
+
switch (type) {
|
32602
|
+
case "numeric":
|
32603
|
+
case "decimal":
|
32604
|
+
case "bigint": {
|
32605
|
+
return sql2`cast(${name2} as text)`;
|
32606
|
+
}
|
32607
|
+
case "blob": {
|
32608
|
+
return sql2`hex(${name2})`;
|
32609
|
+
}
|
32610
|
+
default: {
|
32611
|
+
return name2;
|
32612
|
+
}
|
32613
|
+
}
|
32614
|
+
}
|
32536
32615
|
mapToDriverValue(value) {
|
32537
32616
|
return typeof this.mapTo === "function" ? this.mapTo(value) : value;
|
32538
32617
|
}
|
@@ -33726,6 +33805,9 @@ var init_dialect2 = __esm({
|
|
33726
33805
|
case "SQLiteNumericBigInt": {
|
33727
33806
|
return sql`cast(${name2} as text) as ${sql.identifier(key)}`;
|
33728
33807
|
}
|
33808
|
+
case "SQLiteCustomColumn": {
|
33809
|
+
return sql`${column6.jsonWrapName(name2, sql)} as ${sql.identifier(key)}`;
|
33810
|
+
}
|
33729
33811
|
default: {
|
33730
33812
|
return sql`${name2} as ${sql.identifier(key)}`;
|
33731
33813
|
}
|
@@ -37335,9 +37417,13 @@ var init_custom3 = __esm({
|
|
37335
37417
|
__publicField(this, "sqlName");
|
37336
37418
|
__publicField(this, "mapTo");
|
37337
37419
|
__publicField(this, "mapFrom");
|
37420
|
+
__publicField(this, "mapJson");
|
37421
|
+
__publicField(this, "wrapName");
|
37338
37422
|
this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
|
37339
37423
|
this.mapTo = config.customTypeParams.toDriver;
|
37340
37424
|
this.mapFrom = config.customTypeParams.fromDriver;
|
37425
|
+
this.mapJson = config.customTypeParams.fromJson;
|
37426
|
+
this.wrapName = config.customTypeParams.jsonWrap;
|
37341
37427
|
}
|
37342
37428
|
getSQLType() {
|
37343
37429
|
return this.sqlName;
|
@@ -37345,6 +37431,30 @@ var init_custom3 = __esm({
|
|
37345
37431
|
mapFromDriverValue(value) {
|
37346
37432
|
return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
|
37347
37433
|
}
|
37434
|
+
mapFromJsonValue(value) {
|
37435
|
+
return typeof this.mapJson === "function" ? this.mapJson(value) : this.mapFromDriverValue(value);
|
37436
|
+
}
|
37437
|
+
jsonWrapName(name2, sql2) {
|
37438
|
+
if (typeof this.wrapName === "function")
|
37439
|
+
return this.wrapName(name2, sql2);
|
37440
|
+
const rawType = this.getSQLType().toLowerCase();
|
37441
|
+
const parenPos = rawType.indexOf("(");
|
37442
|
+
const type = parenPos + 1 ? rawType.slice(0, parenPos) : rawType;
|
37443
|
+
switch (type) {
|
37444
|
+
case "binary":
|
37445
|
+
case "varbinary":
|
37446
|
+
case "time":
|
37447
|
+
case "datetime":
|
37448
|
+
case "decimal":
|
37449
|
+
case "float":
|
37450
|
+
case "bigint": {
|
37451
|
+
return sql2`cast(${name2} as char)`;
|
37452
|
+
}
|
37453
|
+
default: {
|
37454
|
+
return name2;
|
37455
|
+
}
|
37456
|
+
}
|
37457
|
+
}
|
37348
37458
|
mapToDriverValue(value) {
|
37349
37459
|
return typeof this.mapTo === "function" ? this.mapTo(value) : value;
|
37350
37460
|
}
|
@@ -39703,6 +39813,9 @@ var init_dialect3 = __esm({
|
|
39703
39813
|
case "MySqlBigInt64": {
|
39704
39814
|
return sql`cast(${name2} as char) as ${sql.identifier(key)}`;
|
39705
39815
|
}
|
39816
|
+
case "MySqlCustomColumn": {
|
39817
|
+
return sql`${column6.jsonWrapName(name2, sql)} as ${sql.identifier(key)}`;
|
39818
|
+
}
|
39706
39819
|
default: {
|
39707
39820
|
return sql`${name2} as ${sql.identifier(key)}`;
|
39708
39821
|
}
|
@@ -43305,9 +43418,13 @@ var init_custom4 = __esm({
|
|
43305
43418
|
__publicField(this, "sqlName");
|
43306
43419
|
__publicField(this, "mapTo");
|
43307
43420
|
__publicField(this, "mapFrom");
|
43421
|
+
__publicField(this, "mapJson");
|
43422
|
+
__publicField(this, "wrapName");
|
43308
43423
|
this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
|
43309
43424
|
this.mapTo = config.customTypeParams.toDriver;
|
43310
43425
|
this.mapFrom = config.customTypeParams.fromDriver;
|
43426
|
+
this.mapJson = config.customTypeParams.fromJson;
|
43427
|
+
this.wrapName = config.customTypeParams.jsonWrap;
|
43311
43428
|
}
|
43312
43429
|
getSQLType() {
|
43313
43430
|
return this.sqlName;
|
@@ -43315,6 +43432,30 @@ var init_custom4 = __esm({
|
|
43315
43432
|
mapFromDriverValue(value) {
|
43316
43433
|
return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
|
43317
43434
|
}
|
43435
|
+
mapFromJsonValue(value) {
|
43436
|
+
return typeof this.mapJson === "function" ? this.mapJson(value) : this.mapFromDriverValue(value);
|
43437
|
+
}
|
43438
|
+
jsonWrapName(name2, sql2) {
|
43439
|
+
if (typeof this.wrapName === "function")
|
43440
|
+
return this.wrapName(name2, sql2);
|
43441
|
+
const rawType = this.getSQLType().toLowerCase();
|
43442
|
+
const parenPos = rawType.indexOf("(");
|
43443
|
+
const type = parenPos + 1 ? rawType.slice(0, parenPos) : rawType;
|
43444
|
+
switch (type) {
|
43445
|
+
case "binary":
|
43446
|
+
case "varbinary":
|
43447
|
+
case "time":
|
43448
|
+
case "datetime":
|
43449
|
+
case "decimal":
|
43450
|
+
case "float":
|
43451
|
+
case "bigint": {
|
43452
|
+
return sql2`cast(${name2} as char)`;
|
43453
|
+
}
|
43454
|
+
default: {
|
43455
|
+
return name2;
|
43456
|
+
}
|
43457
|
+
}
|
43458
|
+
}
|
43318
43459
|
mapToDriverValue(value) {
|
43319
43460
|
return typeof this.mapTo === "function" ? this.mapTo(value) : value;
|
43320
43461
|
}
|
package/bin.cjs
CHANGED
@@ -92729,7 +92729,7 @@ init_utils5();
|
|
92729
92729
|
var version2 = async () => {
|
92730
92730
|
const { npmVersion } = await ormCoreVersions();
|
92731
92731
|
const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
|
92732
|
-
const envVersion = "1.0.0-beta.1-
|
92732
|
+
const envVersion = "1.0.0-beta.1-6b935a0";
|
92733
92733
|
const kitVersion = envVersion ? `v${envVersion}` : "--";
|
92734
92734
|
const versions = `drizzle-kit: ${kitVersion}
|
92735
92735
|
${ormVersion}`;
|