drizzle-kit 1.0.0-beta.1-bd417c1 → 1.0.0-beta.1-03aea0b
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 +132 -4
- package/api.mjs +132 -4
- 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
|
}
|
@@ -24858,9 +24866,13 @@ var init_custom = __esm({
|
|
24858
24866
|
__publicField(this, "sqlName");
|
24859
24867
|
__publicField(this, "mapTo");
|
24860
24868
|
__publicField(this, "mapFrom");
|
24869
|
+
__publicField(this, "mapJson");
|
24870
|
+
__publicField(this, "forJsonSelect");
|
24861
24871
|
this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
|
24862
24872
|
this.mapTo = config.customTypeParams.toDriver;
|
24863
24873
|
this.mapFrom = config.customTypeParams.fromDriver;
|
24874
|
+
this.mapJson = config.customTypeParams.fromJson;
|
24875
|
+
this.forJsonSelect = config.customTypeParams.forJsonSelect;
|
24864
24876
|
}
|
24865
24877
|
getSQLType() {
|
24866
24878
|
return this.sqlName;
|
@@ -24868,6 +24880,29 @@ var init_custom = __esm({
|
|
24868
24880
|
mapFromDriverValue(value) {
|
24869
24881
|
return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
|
24870
24882
|
}
|
24883
|
+
mapFromJsonValue(value) {
|
24884
|
+
return typeof this.mapJson === "function" ? this.mapJson(value) : this.mapFromDriverValue(value);
|
24885
|
+
}
|
24886
|
+
jsonSelectIdentifier(identifier, sql2, arrayDimensions) {
|
24887
|
+
if (typeof this.forJsonSelect === "function")
|
24888
|
+
return this.forJsonSelect(identifier, 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`${identifier}::text${sql2.raw(arrVal).if(arrayDimensions)}`;
|
24900
|
+
}
|
24901
|
+
default: {
|
24902
|
+
return identifier;
|
24903
|
+
}
|
24904
|
+
}
|
24905
|
+
}
|
24871
24906
|
mapToDriverValue(value) {
|
24872
24907
|
return typeof this.mapTo === "function" ? this.mapTo(value) : value;
|
24873
24908
|
}
|
@@ -27550,11 +27585,11 @@ var init_dialect = __esm({
|
|
27550
27585
|
const name2 = sql`${table6}.${sql.identifier(this.casing.getColumnCasing(column6))}`;
|
27551
27586
|
let targetType = column6.columnType;
|
27552
27587
|
let col = column6;
|
27553
|
-
let
|
27588
|
+
let dimensionCnt = 0;
|
27554
27589
|
while (is(col, PgArray)) {
|
27555
|
-
col =
|
27590
|
+
col = col.baseColumn;
|
27556
27591
|
targetType = col.columnType;
|
27557
|
-
|
27592
|
+
++dimensionCnt;
|
27558
27593
|
}
|
27559
27594
|
switch (targetType) {
|
27560
27595
|
case "PgNumeric":
|
@@ -27566,8 +27601,12 @@ var init_dialect = __esm({
|
|
27566
27601
|
case "PgGeometry":
|
27567
27602
|
case "PgGeometryObject":
|
27568
27603
|
case "PgBytea": {
|
27604
|
+
const arrVal = "[]".repeat(dimensionCnt);
|
27569
27605
|
return sql`${name2}::text${sql.raw(arrVal).if(arrVal)} as ${sql.identifier(key)}`;
|
27570
27606
|
}
|
27607
|
+
case "PgCustomColumn": {
|
27608
|
+
return sql`${col.jsonSelectIdentifier(name2, sql, dimensionCnt > 0 ? dimensionCnt : void 0)} as ${sql.identifier(key)}`;
|
27609
|
+
}
|
27571
27610
|
default: {
|
27572
27611
|
return sql`${name2} as ${sql.identifier(key)}`;
|
27573
27612
|
}
|
@@ -32531,9 +32570,13 @@ var init_custom2 = __esm({
|
|
32531
32570
|
__publicField(this, "sqlName");
|
32532
32571
|
__publicField(this, "mapTo");
|
32533
32572
|
__publicField(this, "mapFrom");
|
32573
|
+
__publicField(this, "mapJson");
|
32574
|
+
__publicField(this, "forJsonSelect");
|
32534
32575
|
this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
|
32535
32576
|
this.mapTo = config.customTypeParams.toDriver;
|
32536
32577
|
this.mapFrom = config.customTypeParams.fromDriver;
|
32578
|
+
this.mapJson = config.customTypeParams.fromJson;
|
32579
|
+
this.forJsonSelect = config.customTypeParams.forJsonSelect;
|
32537
32580
|
}
|
32538
32581
|
getSQLType() {
|
32539
32582
|
return this.sqlName;
|
@@ -32541,6 +32584,29 @@ var init_custom2 = __esm({
|
|
32541
32584
|
mapFromDriverValue(value) {
|
32542
32585
|
return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
|
32543
32586
|
}
|
32587
|
+
mapFromJsonValue(value) {
|
32588
|
+
return typeof this.mapJson === "function" ? this.mapJson(value) : this.mapFromDriverValue(value);
|
32589
|
+
}
|
32590
|
+
jsonSelectIdentifier(identifier, sql2) {
|
32591
|
+
if (typeof this.forJsonSelect === "function")
|
32592
|
+
return this.forJsonSelect(identifier, 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(${identifier} as text)`;
|
32601
|
+
}
|
32602
|
+
case "blob": {
|
32603
|
+
return sql2`hex(${identifier})`;
|
32604
|
+
}
|
32605
|
+
default: {
|
32606
|
+
return identifier;
|
32607
|
+
}
|
32608
|
+
}
|
32609
|
+
}
|
32544
32610
|
mapToDriverValue(value) {
|
32545
32611
|
return typeof this.mapTo === "function" ? this.mapTo(value) : value;
|
32546
32612
|
}
|
@@ -33734,6 +33800,9 @@ var init_dialect2 = __esm({
|
|
33734
33800
|
case "SQLiteNumericBigInt": {
|
33735
33801
|
return sql`cast(${name2} as text) as ${sql.identifier(key)}`;
|
33736
33802
|
}
|
33803
|
+
case "SQLiteCustomColumn": {
|
33804
|
+
return sql`${column6.jsonSelectIdentifier(name2, sql)} as ${sql.identifier(key)}`;
|
33805
|
+
}
|
33737
33806
|
default: {
|
33738
33807
|
return sql`${name2} as ${sql.identifier(key)}`;
|
33739
33808
|
}
|
@@ -37343,9 +37412,13 @@ var init_custom3 = __esm({
|
|
37343
37412
|
__publicField(this, "sqlName");
|
37344
37413
|
__publicField(this, "mapTo");
|
37345
37414
|
__publicField(this, "mapFrom");
|
37415
|
+
__publicField(this, "mapJson");
|
37416
|
+
__publicField(this, "forJsonSelect");
|
37346
37417
|
this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
|
37347
37418
|
this.mapTo = config.customTypeParams.toDriver;
|
37348
37419
|
this.mapFrom = config.customTypeParams.fromDriver;
|
37420
|
+
this.mapJson = config.customTypeParams.fromJson;
|
37421
|
+
this.forJsonSelect = config.customTypeParams.forJsonSelect;
|
37349
37422
|
}
|
37350
37423
|
getSQLType() {
|
37351
37424
|
return this.sqlName;
|
@@ -37353,6 +37426,30 @@ var init_custom3 = __esm({
|
|
37353
37426
|
mapFromDriverValue(value) {
|
37354
37427
|
return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
|
37355
37428
|
}
|
37429
|
+
mapFromJsonValue(value) {
|
37430
|
+
return typeof this.mapJson === "function" ? this.mapJson(value) : this.mapFromDriverValue(value);
|
37431
|
+
}
|
37432
|
+
jsonSelectIdentifier(identifier, sql2) {
|
37433
|
+
if (typeof this.forJsonSelect === "function")
|
37434
|
+
return this.forJsonSelect(identifier, 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(${identifier} as char)`;
|
37447
|
+
}
|
37448
|
+
default: {
|
37449
|
+
return identifier;
|
37450
|
+
}
|
37451
|
+
}
|
37452
|
+
}
|
37356
37453
|
mapToDriverValue(value) {
|
37357
37454
|
return typeof this.mapTo === "function" ? this.mapTo(value) : value;
|
37358
37455
|
}
|
@@ -39711,6 +39808,9 @@ var init_dialect3 = __esm({
|
|
39711
39808
|
case "MySqlBigInt64": {
|
39712
39809
|
return sql`cast(${name2} as char) as ${sql.identifier(key)}`;
|
39713
39810
|
}
|
39811
|
+
case "MySqlCustomColumn": {
|
39812
|
+
return sql`${column6.jsonSelectIdentifier(name2, sql)} as ${sql.identifier(key)}`;
|
39813
|
+
}
|
39714
39814
|
default: {
|
39715
39815
|
return sql`${name2} as ${sql.identifier(key)}`;
|
39716
39816
|
}
|
@@ -43313,9 +43413,13 @@ var init_custom4 = __esm({
|
|
43313
43413
|
__publicField(this, "sqlName");
|
43314
43414
|
__publicField(this, "mapTo");
|
43315
43415
|
__publicField(this, "mapFrom");
|
43416
|
+
__publicField(this, "mapJson");
|
43417
|
+
__publicField(this, "forJsonSelect");
|
43316
43418
|
this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
|
43317
43419
|
this.mapTo = config.customTypeParams.toDriver;
|
43318
43420
|
this.mapFrom = config.customTypeParams.fromDriver;
|
43421
|
+
this.mapJson = config.customTypeParams.fromJson;
|
43422
|
+
this.forJsonSelect = config.customTypeParams.forJsonSelect;
|
43319
43423
|
}
|
43320
43424
|
getSQLType() {
|
43321
43425
|
return this.sqlName;
|
@@ -43323,6 +43427,30 @@ var init_custom4 = __esm({
|
|
43323
43427
|
mapFromDriverValue(value) {
|
43324
43428
|
return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
|
43325
43429
|
}
|
43430
|
+
mapFromJsonValue(value) {
|
43431
|
+
return typeof this.mapJson === "function" ? this.mapJson(value) : this.mapFromDriverValue(value);
|
43432
|
+
}
|
43433
|
+
jsonSelectIdentifier(identifier, sql2) {
|
43434
|
+
if (typeof this.forJsonSelect === "function")
|
43435
|
+
return this.forJsonSelect(identifier, 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(${identifier} as char)`;
|
43448
|
+
}
|
43449
|
+
default: {
|
43450
|
+
return identifier;
|
43451
|
+
}
|
43452
|
+
}
|
43453
|
+
}
|
43326
43454
|
mapToDriverValue(value) {
|
43327
43455
|
return typeof this.mapTo === "function" ? this.mapTo(value) : value;
|
43328
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
|
}
|
@@ -24863,9 +24871,13 @@ var init_custom = __esm({
|
|
24863
24871
|
__publicField(this, "sqlName");
|
24864
24872
|
__publicField(this, "mapTo");
|
24865
24873
|
__publicField(this, "mapFrom");
|
24874
|
+
__publicField(this, "mapJson");
|
24875
|
+
__publicField(this, "forJsonSelect");
|
24866
24876
|
this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
|
24867
24877
|
this.mapTo = config.customTypeParams.toDriver;
|
24868
24878
|
this.mapFrom = config.customTypeParams.fromDriver;
|
24879
|
+
this.mapJson = config.customTypeParams.fromJson;
|
24880
|
+
this.forJsonSelect = config.customTypeParams.forJsonSelect;
|
24869
24881
|
}
|
24870
24882
|
getSQLType() {
|
24871
24883
|
return this.sqlName;
|
@@ -24873,6 +24885,29 @@ var init_custom = __esm({
|
|
24873
24885
|
mapFromDriverValue(value) {
|
24874
24886
|
return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
|
24875
24887
|
}
|
24888
|
+
mapFromJsonValue(value) {
|
24889
|
+
return typeof this.mapJson === "function" ? this.mapJson(value) : this.mapFromDriverValue(value);
|
24890
|
+
}
|
24891
|
+
jsonSelectIdentifier(identifier, sql2, arrayDimensions) {
|
24892
|
+
if (typeof this.forJsonSelect === "function")
|
24893
|
+
return this.forJsonSelect(identifier, 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`${identifier}::text${sql2.raw(arrVal).if(arrayDimensions)}`;
|
24905
|
+
}
|
24906
|
+
default: {
|
24907
|
+
return identifier;
|
24908
|
+
}
|
24909
|
+
}
|
24910
|
+
}
|
24876
24911
|
mapToDriverValue(value) {
|
24877
24912
|
return typeof this.mapTo === "function" ? this.mapTo(value) : value;
|
24878
24913
|
}
|
@@ -27555,11 +27590,11 @@ var init_dialect = __esm({
|
|
27555
27590
|
const name2 = sql`${table6}.${sql.identifier(this.casing.getColumnCasing(column6))}`;
|
27556
27591
|
let targetType = column6.columnType;
|
27557
27592
|
let col = column6;
|
27558
|
-
let
|
27593
|
+
let dimensionCnt = 0;
|
27559
27594
|
while (is(col, PgArray)) {
|
27560
|
-
col =
|
27595
|
+
col = col.baseColumn;
|
27561
27596
|
targetType = col.columnType;
|
27562
|
-
|
27597
|
+
++dimensionCnt;
|
27563
27598
|
}
|
27564
27599
|
switch (targetType) {
|
27565
27600
|
case "PgNumeric":
|
@@ -27571,8 +27606,12 @@ var init_dialect = __esm({
|
|
27571
27606
|
case "PgGeometry":
|
27572
27607
|
case "PgGeometryObject":
|
27573
27608
|
case "PgBytea": {
|
27609
|
+
const arrVal = "[]".repeat(dimensionCnt);
|
27574
27610
|
return sql`${name2}::text${sql.raw(arrVal).if(arrVal)} as ${sql.identifier(key)}`;
|
27575
27611
|
}
|
27612
|
+
case "PgCustomColumn": {
|
27613
|
+
return sql`${col.jsonSelectIdentifier(name2, sql, dimensionCnt > 0 ? dimensionCnt : void 0)} as ${sql.identifier(key)}`;
|
27614
|
+
}
|
27576
27615
|
default: {
|
27577
27616
|
return sql`${name2} as ${sql.identifier(key)}`;
|
27578
27617
|
}
|
@@ -32536,9 +32575,13 @@ var init_custom2 = __esm({
|
|
32536
32575
|
__publicField(this, "sqlName");
|
32537
32576
|
__publicField(this, "mapTo");
|
32538
32577
|
__publicField(this, "mapFrom");
|
32578
|
+
__publicField(this, "mapJson");
|
32579
|
+
__publicField(this, "forJsonSelect");
|
32539
32580
|
this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
|
32540
32581
|
this.mapTo = config.customTypeParams.toDriver;
|
32541
32582
|
this.mapFrom = config.customTypeParams.fromDriver;
|
32583
|
+
this.mapJson = config.customTypeParams.fromJson;
|
32584
|
+
this.forJsonSelect = config.customTypeParams.forJsonSelect;
|
32542
32585
|
}
|
32543
32586
|
getSQLType() {
|
32544
32587
|
return this.sqlName;
|
@@ -32546,6 +32589,29 @@ var init_custom2 = __esm({
|
|
32546
32589
|
mapFromDriverValue(value) {
|
32547
32590
|
return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
|
32548
32591
|
}
|
32592
|
+
mapFromJsonValue(value) {
|
32593
|
+
return typeof this.mapJson === "function" ? this.mapJson(value) : this.mapFromDriverValue(value);
|
32594
|
+
}
|
32595
|
+
jsonSelectIdentifier(identifier, sql2) {
|
32596
|
+
if (typeof this.forJsonSelect === "function")
|
32597
|
+
return this.forJsonSelect(identifier, 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(${identifier} as text)`;
|
32606
|
+
}
|
32607
|
+
case "blob": {
|
32608
|
+
return sql2`hex(${identifier})`;
|
32609
|
+
}
|
32610
|
+
default: {
|
32611
|
+
return identifier;
|
32612
|
+
}
|
32613
|
+
}
|
32614
|
+
}
|
32549
32615
|
mapToDriverValue(value) {
|
32550
32616
|
return typeof this.mapTo === "function" ? this.mapTo(value) : value;
|
32551
32617
|
}
|
@@ -33739,6 +33805,9 @@ var init_dialect2 = __esm({
|
|
33739
33805
|
case "SQLiteNumericBigInt": {
|
33740
33806
|
return sql`cast(${name2} as text) as ${sql.identifier(key)}`;
|
33741
33807
|
}
|
33808
|
+
case "SQLiteCustomColumn": {
|
33809
|
+
return sql`${column6.jsonSelectIdentifier(name2, sql)} as ${sql.identifier(key)}`;
|
33810
|
+
}
|
33742
33811
|
default: {
|
33743
33812
|
return sql`${name2} as ${sql.identifier(key)}`;
|
33744
33813
|
}
|
@@ -37348,9 +37417,13 @@ var init_custom3 = __esm({
|
|
37348
37417
|
__publicField(this, "sqlName");
|
37349
37418
|
__publicField(this, "mapTo");
|
37350
37419
|
__publicField(this, "mapFrom");
|
37420
|
+
__publicField(this, "mapJson");
|
37421
|
+
__publicField(this, "forJsonSelect");
|
37351
37422
|
this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
|
37352
37423
|
this.mapTo = config.customTypeParams.toDriver;
|
37353
37424
|
this.mapFrom = config.customTypeParams.fromDriver;
|
37425
|
+
this.mapJson = config.customTypeParams.fromJson;
|
37426
|
+
this.forJsonSelect = config.customTypeParams.forJsonSelect;
|
37354
37427
|
}
|
37355
37428
|
getSQLType() {
|
37356
37429
|
return this.sqlName;
|
@@ -37358,6 +37431,30 @@ var init_custom3 = __esm({
|
|
37358
37431
|
mapFromDriverValue(value) {
|
37359
37432
|
return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
|
37360
37433
|
}
|
37434
|
+
mapFromJsonValue(value) {
|
37435
|
+
return typeof this.mapJson === "function" ? this.mapJson(value) : this.mapFromDriverValue(value);
|
37436
|
+
}
|
37437
|
+
jsonSelectIdentifier(identifier, sql2) {
|
37438
|
+
if (typeof this.forJsonSelect === "function")
|
37439
|
+
return this.forJsonSelect(identifier, 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(${identifier} as char)`;
|
37452
|
+
}
|
37453
|
+
default: {
|
37454
|
+
return identifier;
|
37455
|
+
}
|
37456
|
+
}
|
37457
|
+
}
|
37361
37458
|
mapToDriverValue(value) {
|
37362
37459
|
return typeof this.mapTo === "function" ? this.mapTo(value) : value;
|
37363
37460
|
}
|
@@ -39716,6 +39813,9 @@ var init_dialect3 = __esm({
|
|
39716
39813
|
case "MySqlBigInt64": {
|
39717
39814
|
return sql`cast(${name2} as char) as ${sql.identifier(key)}`;
|
39718
39815
|
}
|
39816
|
+
case "MySqlCustomColumn": {
|
39817
|
+
return sql`${column6.jsonSelectIdentifier(name2, sql)} as ${sql.identifier(key)}`;
|
39818
|
+
}
|
39719
39819
|
default: {
|
39720
39820
|
return sql`${name2} as ${sql.identifier(key)}`;
|
39721
39821
|
}
|
@@ -43318,9 +43418,13 @@ var init_custom4 = __esm({
|
|
43318
43418
|
__publicField(this, "sqlName");
|
43319
43419
|
__publicField(this, "mapTo");
|
43320
43420
|
__publicField(this, "mapFrom");
|
43421
|
+
__publicField(this, "mapJson");
|
43422
|
+
__publicField(this, "forJsonSelect");
|
43321
43423
|
this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
|
43322
43424
|
this.mapTo = config.customTypeParams.toDriver;
|
43323
43425
|
this.mapFrom = config.customTypeParams.fromDriver;
|
43426
|
+
this.mapJson = config.customTypeParams.fromJson;
|
43427
|
+
this.forJsonSelect = config.customTypeParams.forJsonSelect;
|
43324
43428
|
}
|
43325
43429
|
getSQLType() {
|
43326
43430
|
return this.sqlName;
|
@@ -43328,6 +43432,30 @@ var init_custom4 = __esm({
|
|
43328
43432
|
mapFromDriverValue(value) {
|
43329
43433
|
return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
|
43330
43434
|
}
|
43435
|
+
mapFromJsonValue(value) {
|
43436
|
+
return typeof this.mapJson === "function" ? this.mapJson(value) : this.mapFromDriverValue(value);
|
43437
|
+
}
|
43438
|
+
jsonSelectIdentifier(identifier, sql2) {
|
43439
|
+
if (typeof this.forJsonSelect === "function")
|
43440
|
+
return this.forJsonSelect(identifier, 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(${identifier} as char)`;
|
43453
|
+
}
|
43454
|
+
default: {
|
43455
|
+
return identifier;
|
43456
|
+
}
|
43457
|
+
}
|
43458
|
+
}
|
43331
43459
|
mapToDriverValue(value) {
|
43332
43460
|
return typeof this.mapTo === "function" ? this.mapTo(value) : value;
|
43333
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-03aea0b";
|
92733
92733
|
const kitVersion = envVersion ? `v${envVersion}` : "--";
|
92734
92734
|
const versions = `drizzle-kit: ${kitVersion}
|
92735
92735
|
${ormVersion}`;
|