drizzle-kit 0.30.5-9fd1115 → 0.30.5-abfca61

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.
Files changed (4) hide show
  1. package/api.js +115 -16
  2. package/api.mjs +115 -16
  3. package/bin.cjs +1 -1
  4. package/package.json +1 -1
package/api.js CHANGED
@@ -23730,10 +23730,10 @@ var init_relations = __esm({
23730
23730
  }
23731
23731
  for (const tableConfig of Object.values(this.tablesConfig)) {
23732
23732
  for (const [relationFieldName, relation] of Object.entries(tableConfig.relations)) {
23733
- const relationPrintName = `relations -> ${tableConfig.tsName}.${relationFieldName}`;
23734
23733
  if (!is(relation, Relation)) {
23735
23734
  continue;
23736
23735
  }
23736
+ const relationPrintName = `relations -> ${tableConfig.tsName}: { ${relationFieldName}: r.${is(relation, One) ? "one" : "many"}.${this.tableNamesMap[getTableUniqueName(relation.targetTable)]}(...) }`;
23737
23737
  if (typeof relation.alias === "string" && !relation.alias) {
23738
23738
  throw new Error(`${relationPrintName}: "alias" cannot be an empty string - omit it if you don't need it`);
23739
23739
  }
@@ -23750,7 +23750,7 @@ var init_relations = __esm({
23750
23750
  );
23751
23751
  }
23752
23752
  if (relation.through) {
23753
- if (relation.through.source.length !== relation.through.target.length || relation.through.source.length !== relation.sourceColumns.length || relation.through.target.length !== relation.targetColumns.length) {
23753
+ if (relation.through.source.length !== relation.sourceColumns.length || relation.through.target.length !== relation.targetColumns.length) {
23754
23754
  throw new Error(
23755
23755
  `${relationPrintName}: ".through(column)" must be used either on all columns in "from" and "to" or not defined on any of them`
23756
23756
  );
@@ -23792,7 +23792,7 @@ var init_relations = __esm({
23792
23792
  }
23793
23793
  if (relation.alias) {
23794
23794
  const reverseRelations = Object.values(reverseTableConfig.relations).filter(
23795
- (it) => is(it, Relation) && it.alias === relation.alias
23795
+ (it) => is(it, Relation) && it.alias === relation.alias && it !== relation
23796
23796
  );
23797
23797
  if (reverseRelations.length > 1) {
23798
23798
  throw new Error(
@@ -23807,7 +23807,7 @@ var init_relations = __esm({
23807
23807
  }
23808
23808
  } else {
23809
23809
  const reverseRelations = Object.values(reverseTableConfig.relations).filter(
23810
- (it) => is(it, Relation) && it.targetTable === relation.sourceTable && !it.alias
23810
+ (it) => is(it, Relation) && it.targetTable === relation.sourceTable && !it.alias && it !== relation
23811
23811
  );
23812
23812
  if (reverseRelations.length > 1) {
23813
23813
  throw new Error(
@@ -25309,6 +25309,11 @@ var init_numeric = __esm({
25309
25309
  this.precision = config.precision;
25310
25310
  this.scale = config.scale;
25311
25311
  }
25312
+ mapFromDriverValue(value) {
25313
+ if (typeof value === "string")
25314
+ return value;
25315
+ return String(value);
25316
+ }
25312
25317
  getSQLType() {
25313
25318
  if (this.precision !== void 0 && this.scale !== void 0) {
25314
25319
  return `numeric(${this.precision}, ${this.scale})`;
@@ -25477,6 +25482,8 @@ var init_geometry = __esm({
25477
25482
  return "geometry(point)";
25478
25483
  }
25479
25484
  mapFromDriverValue(value) {
25485
+ if (typeof value !== "string")
25486
+ return value;
25480
25487
  return parseEWKB(value);
25481
25488
  }
25482
25489
  mapToDriverValue(value) {
@@ -26683,6 +26690,7 @@ var _a136, CasingCache;
26683
26690
  var init_casing = __esm({
26684
26691
  "../drizzle-orm/dist/casing.js"() {
26685
26692
  "use strict";
26693
+ init_column();
26686
26694
  init_entity();
26687
26695
  init_table();
26688
26696
  _a136 = entityKind;
@@ -26711,6 +26719,8 @@ var init_casing = __esm({
26711
26719
  const tableKey2 = `${schema5}.${tableName}`;
26712
26720
  if (!this.cachedTables[tableKey2]) {
26713
26721
  for (const column6 of Object.values(table6[Table2.Symbol.Columns])) {
26722
+ if (!is(column6, Column2))
26723
+ continue;
26714
26724
  const columnKey = `${tableKey2}.${column6.name}`;
26715
26725
  this.cache[columnKey] = this.convert(column6.name);
26716
26726
  }
@@ -27423,12 +27433,26 @@ var init_dialect = __esm({
27423
27433
  }
27424
27434
  buildRqbColumn(table6, column6, key) {
27425
27435
  if (is(column6, Column2)) {
27426
- switch (column6.columnType) {
27427
- case "PgBigInt64": {
27428
- return sql`${table6}.${sql.identifier(column6.name)}::text as ${sql.identifier(key)}`;
27436
+ const name2 = sql`${table6}.${sql.identifier(this.casing.getColumnCasing(column6))}`;
27437
+ let targetType = column6.columnType;
27438
+ let col = column6;
27439
+ let arrVal = "";
27440
+ while (is(col, PgArray)) {
27441
+ col = column6.baseColumn;
27442
+ targetType = col.columnType;
27443
+ arrVal = arrVal + "[]";
27444
+ }
27445
+ switch (targetType) {
27446
+ case "PgNumeric":
27447
+ case "PgBigInt64":
27448
+ case "PgBigSerial64":
27449
+ case "PgTimestampString":
27450
+ case "PgGeometry":
27451
+ case "PgGeometryObject": {
27452
+ return sql`${name2}::text${sql.raw(arrVal).if(arrVal)} as ${sql.identifier(key)}`;
27429
27453
  }
27430
27454
  default: {
27431
- return sql`${table6}.${sql.identifier(column6.name)} as ${sql.identifier(key)}`;
27455
+ return sql`${name2} as ${sql.identifier(key)}`;
27432
27456
  }
27433
27457
  }
27434
27458
  }
@@ -32247,6 +32271,9 @@ var init_blob = __esm({
32247
32271
  if (Buffer.isBuffer(value)) {
32248
32272
  return BigInt(value.toString());
32249
32273
  }
32274
+ if (typeof value === "string") {
32275
+ return BigInt(Buffer.from(value, "hex").toString());
32276
+ }
32250
32277
  if (value instanceof ArrayBuffer) {
32251
32278
  const decoder = new TextDecoder();
32252
32279
  return BigInt(decoder.decode(value));
@@ -32279,6 +32306,9 @@ var init_blob = __esm({
32279
32306
  if (Buffer.isBuffer(value)) {
32280
32307
  return JSON.parse(value.toString());
32281
32308
  }
32309
+ if (typeof value === "string") {
32310
+ return JSON.parse(Buffer.from(value, "hex").toString());
32311
+ }
32282
32312
  if (value instanceof ArrayBuffer) {
32283
32313
  const decoder = new TextDecoder();
32284
32314
  return JSON.parse(decoder.decode(value));
@@ -32301,6 +32331,12 @@ var init_blob = __esm({
32301
32331
  };
32302
32332
  __publicField(SQLiteBlobBufferBuilder, _a187, "SQLiteBlobBufferBuilder");
32303
32333
  SQLiteBlobBuffer = class extends (_b125 = SQLiteColumn, _a188 = entityKind, _b125) {
32334
+ mapFromDriverValue(value) {
32335
+ if (typeof value === "string") {
32336
+ return Buffer.from(value, "hex");
32337
+ }
32338
+ return value;
32339
+ }
32304
32340
  getSQLType() {
32305
32341
  return "blob";
32306
32342
  }
@@ -32879,7 +32915,7 @@ var init_dialect2 = __esm({
32879
32915
  key: k,
32880
32916
  field: v
32881
32917
  });
32882
- return sql`${table6}.${this.buildRqbColumn(v, k)}`;
32918
+ return this.buildRqbColumn(table6, v, k);
32883
32919
  }),
32884
32920
  sql`, `
32885
32921
  );
@@ -32917,7 +32953,7 @@ var init_dialect2 = __esm({
32917
32953
  const columnIdentifiers = [];
32918
32954
  const selectedColumns = this.getSelectedTableColumns(table6, params?.columns);
32919
32955
  for (const { column: column6, tsName } of selectedColumns) {
32920
- columnIdentifiers.push(sql`${table6}.${this.buildRqbColumn(column6, tsName)}`);
32956
+ columnIdentifiers.push(this.buildRqbColumn(table6, column6, tsName));
32921
32957
  selection.push({
32922
32958
  key: tsName,
32923
32959
  field: column6
@@ -33467,8 +33503,21 @@ var init_dialect2 = __esm({
33467
33503
  message: `Views with nested selections are not supported by the relational query builder`
33468
33504
  });
33469
33505
  }
33470
- buildRqbColumn(column6, key) {
33471
- return sql`${is(column6, Column2) ? sql.identifier(this.casing.getColumnCasing(column6)) : is(column6, SQL.Aliased) ? sql.identifier(column6.fieldAlias) : isSQLWrapper(column6) ? sql.identifier(key) : this.nestedSelectionerror()} as ${sql.identifier(key)}`;
33506
+ buildRqbColumn(table6, column6, key) {
33507
+ if (is(column6, Column2)) {
33508
+ const name2 = sql`${table6}.${sql.identifier(this.casing.getColumnCasing(column6))}`;
33509
+ switch (column6.columnType) {
33510
+ case "SQLiteBigInt":
33511
+ case "SQLiteBlobJson":
33512
+ case "SQLiteBlobBuffer": {
33513
+ return sql`hex(${name2}) as ${sql.identifier(key)}`;
33514
+ }
33515
+ default: {
33516
+ return sql`${name2} as ${sql.identifier(key)}`;
33517
+ }
33518
+ }
33519
+ }
33520
+ return sql`${table6}.${is(column6, SQL.Aliased) ? sql.identifier(column6.fieldAlias) : isSQLWrapper(column6) ? sql.identifier(key) : this.nestedSelectionerror()} as ${sql.identifier(key)}`;
33472
33521
  }
33473
33522
  buildRelationalQuery({
33474
33523
  tables,
@@ -36912,6 +36961,17 @@ var init_binary = __esm({
36912
36961
  super(...arguments);
36913
36962
  __publicField(this, "length", this.config.length);
36914
36963
  }
36964
+ mapFromDriverValue(value) {
36965
+ if (typeof value === "string")
36966
+ return value;
36967
+ if (Buffer.isBuffer(value))
36968
+ return value.toString();
36969
+ const str = [];
36970
+ for (const v of value) {
36971
+ str.push(v === 49 ? "1" : "0");
36972
+ }
36973
+ return str.join("");
36974
+ }
36915
36975
  getSQLType() {
36916
36976
  return this.length === void 0 ? `binary` : `binary(${this.length})`;
36917
36977
  }
@@ -37225,6 +37285,11 @@ var init_decimal = __esm({
37225
37285
  __publicField(this, "scale", this.config.scale);
37226
37286
  __publicField(this, "unsigned", this.config.unsigned);
37227
37287
  }
37288
+ mapFromDriverValue(value) {
37289
+ if (typeof value === "string")
37290
+ return value;
37291
+ return String(value);
37292
+ }
37228
37293
  getSQLType() {
37229
37294
  let type = "";
37230
37295
  if (this.precision !== void 0 && this.scale !== void 0) {
@@ -37364,6 +37429,12 @@ var init_float = __esm({
37364
37429
  __publicField(this, "scale", this.config.scale);
37365
37430
  __publicField(this, "unsigned", this.config.unsigned);
37366
37431
  }
37432
+ mapFromDriverValue(value) {
37433
+ if (typeof value === "string") {
37434
+ return Number(value);
37435
+ }
37436
+ return value;
37437
+ }
37367
37438
  getSQLType() {
37368
37439
  let type = "";
37369
37440
  if (this.precision !== void 0 && this.scale !== void 0) {
@@ -37877,6 +37948,17 @@ var init_varbinary = __esm({
37877
37948
  super(...arguments);
37878
37949
  __publicField(this, "length", this.config.length);
37879
37950
  }
37951
+ mapFromDriverValue(value) {
37952
+ if (typeof value === "string")
37953
+ return value;
37954
+ if (Buffer.isBuffer(value))
37955
+ return value.toString();
37956
+ const str = [];
37957
+ for (const v of value) {
37958
+ str.push(v === 49 ? "1" : "0");
37959
+ }
37960
+ return str.join("");
37961
+ }
37880
37962
  getSQLType() {
37881
37963
  return this.length === void 0 ? `varbinary` : `varbinary(${this.length})`;
37882
37964
  }
@@ -38422,7 +38504,7 @@ var init_dialect3 = __esm({
38422
38504
  key: k,
38423
38505
  field: v
38424
38506
  });
38425
- return sql`${table6}.${this.buildRqbColumn(v, k)}`;
38507
+ return this.buildRqbColumn(table6, v, k);
38426
38508
  }),
38427
38509
  sql`, `
38428
38510
  );
@@ -38460,7 +38542,7 @@ var init_dialect3 = __esm({
38460
38542
  const columnIdentifiers = [];
38461
38543
  const selectedColumns = this.getSelectedTableColumns(table6, params.columns);
38462
38544
  for (const { column: column6, tsName } of selectedColumns) {
38463
- columnIdentifiers.push(sql`${table6}.${this.buildRqbColumn(column6, tsName)}`);
38545
+ columnIdentifiers.push(this.buildRqbColumn(table6, column6, tsName));
38464
38546
  selection.push({
38465
38547
  key: tsName,
38466
38548
  field: column6
@@ -39281,8 +39363,25 @@ var init_dialect3 = __esm({
39281
39363
  message: `Views with nested selections are not supported by the relational query builder`
39282
39364
  });
39283
39365
  }
39284
- buildRqbColumn(column6, key) {
39285
- return sql`${is(column6, Column2) ? sql.identifier(this.casing.getColumnCasing(column6)) : is(column6, SQL.Aliased) ? sql.identifier(column6.fieldAlias) : isSQLWrapper(column6) ? sql.identifier(key) : this.nestedSelectionerror()} as ${sql.identifier(key)}`;
39366
+ buildRqbColumn(table6, column6, key) {
39367
+ if (is(column6, Column2)) {
39368
+ const name2 = sql`${table6}.${sql.identifier(this.casing.getColumnCasing(column6))}`;
39369
+ switch (column6.columnType) {
39370
+ case "MySqlBinary":
39371
+ case "MySqlVarBinary":
39372
+ case "MySqlTime":
39373
+ case "MySqlDateTimeString":
39374
+ case "MySqlTimestampString":
39375
+ case "MySqlFloat":
39376
+ case "MySqlBigInt64": {
39377
+ return sql`cast(${name2} as char) as ${sql.identifier(key)}`;
39378
+ }
39379
+ default: {
39380
+ return sql`${name2} as ${sql.identifier(key)}`;
39381
+ }
39382
+ }
39383
+ }
39384
+ return sql`${table6}.${is(column6, SQL.Aliased) ? sql.identifier(column6.fieldAlias) : isSQLWrapper(column6) ? sql.identifier(key) : this.nestedSelectionerror()} as ${sql.identifier(key)}`;
39286
39385
  }
39287
39386
  buildRelationalQuery({
39288
39387
  tables,
package/api.mjs CHANGED
@@ -23735,10 +23735,10 @@ var init_relations = __esm({
23735
23735
  }
23736
23736
  for (const tableConfig of Object.values(this.tablesConfig)) {
23737
23737
  for (const [relationFieldName, relation] of Object.entries(tableConfig.relations)) {
23738
- const relationPrintName = `relations -> ${tableConfig.tsName}.${relationFieldName}`;
23739
23738
  if (!is(relation, Relation)) {
23740
23739
  continue;
23741
23740
  }
23741
+ const relationPrintName = `relations -> ${tableConfig.tsName}: { ${relationFieldName}: r.${is(relation, One) ? "one" : "many"}.${this.tableNamesMap[getTableUniqueName(relation.targetTable)]}(...) }`;
23742
23742
  if (typeof relation.alias === "string" && !relation.alias) {
23743
23743
  throw new Error(`${relationPrintName}: "alias" cannot be an empty string - omit it if you don't need it`);
23744
23744
  }
@@ -23755,7 +23755,7 @@ var init_relations = __esm({
23755
23755
  );
23756
23756
  }
23757
23757
  if (relation.through) {
23758
- if (relation.through.source.length !== relation.through.target.length || relation.through.source.length !== relation.sourceColumns.length || relation.through.target.length !== relation.targetColumns.length) {
23758
+ if (relation.through.source.length !== relation.sourceColumns.length || relation.through.target.length !== relation.targetColumns.length) {
23759
23759
  throw new Error(
23760
23760
  `${relationPrintName}: ".through(column)" must be used either on all columns in "from" and "to" or not defined on any of them`
23761
23761
  );
@@ -23797,7 +23797,7 @@ var init_relations = __esm({
23797
23797
  }
23798
23798
  if (relation.alias) {
23799
23799
  const reverseRelations = Object.values(reverseTableConfig.relations).filter(
23800
- (it) => is(it, Relation) && it.alias === relation.alias
23800
+ (it) => is(it, Relation) && it.alias === relation.alias && it !== relation
23801
23801
  );
23802
23802
  if (reverseRelations.length > 1) {
23803
23803
  throw new Error(
@@ -23812,7 +23812,7 @@ var init_relations = __esm({
23812
23812
  }
23813
23813
  } else {
23814
23814
  const reverseRelations = Object.values(reverseTableConfig.relations).filter(
23815
- (it) => is(it, Relation) && it.targetTable === relation.sourceTable && !it.alias
23815
+ (it) => is(it, Relation) && it.targetTable === relation.sourceTable && !it.alias && it !== relation
23816
23816
  );
23817
23817
  if (reverseRelations.length > 1) {
23818
23818
  throw new Error(
@@ -25314,6 +25314,11 @@ var init_numeric = __esm({
25314
25314
  this.precision = config.precision;
25315
25315
  this.scale = config.scale;
25316
25316
  }
25317
+ mapFromDriverValue(value) {
25318
+ if (typeof value === "string")
25319
+ return value;
25320
+ return String(value);
25321
+ }
25317
25322
  getSQLType() {
25318
25323
  if (this.precision !== void 0 && this.scale !== void 0) {
25319
25324
  return `numeric(${this.precision}, ${this.scale})`;
@@ -25482,6 +25487,8 @@ var init_geometry = __esm({
25482
25487
  return "geometry(point)";
25483
25488
  }
25484
25489
  mapFromDriverValue(value) {
25490
+ if (typeof value !== "string")
25491
+ return value;
25485
25492
  return parseEWKB(value);
25486
25493
  }
25487
25494
  mapToDriverValue(value) {
@@ -26688,6 +26695,7 @@ var _a136, CasingCache;
26688
26695
  var init_casing = __esm({
26689
26696
  "../drizzle-orm/dist/casing.js"() {
26690
26697
  "use strict";
26698
+ init_column();
26691
26699
  init_entity();
26692
26700
  init_table();
26693
26701
  _a136 = entityKind;
@@ -26716,6 +26724,8 @@ var init_casing = __esm({
26716
26724
  const tableKey2 = `${schema5}.${tableName}`;
26717
26725
  if (!this.cachedTables[tableKey2]) {
26718
26726
  for (const column6 of Object.values(table6[Table2.Symbol.Columns])) {
26727
+ if (!is(column6, Column2))
26728
+ continue;
26719
26729
  const columnKey = `${tableKey2}.${column6.name}`;
26720
26730
  this.cache[columnKey] = this.convert(column6.name);
26721
26731
  }
@@ -27428,12 +27438,26 @@ var init_dialect = __esm({
27428
27438
  }
27429
27439
  buildRqbColumn(table6, column6, key) {
27430
27440
  if (is(column6, Column2)) {
27431
- switch (column6.columnType) {
27432
- case "PgBigInt64": {
27433
- return sql`${table6}.${sql.identifier(column6.name)}::text as ${sql.identifier(key)}`;
27441
+ const name2 = sql`${table6}.${sql.identifier(this.casing.getColumnCasing(column6))}`;
27442
+ let targetType = column6.columnType;
27443
+ let col = column6;
27444
+ let arrVal = "";
27445
+ while (is(col, PgArray)) {
27446
+ col = column6.baseColumn;
27447
+ targetType = col.columnType;
27448
+ arrVal = arrVal + "[]";
27449
+ }
27450
+ switch (targetType) {
27451
+ case "PgNumeric":
27452
+ case "PgBigInt64":
27453
+ case "PgBigSerial64":
27454
+ case "PgTimestampString":
27455
+ case "PgGeometry":
27456
+ case "PgGeometryObject": {
27457
+ return sql`${name2}::text${sql.raw(arrVal).if(arrVal)} as ${sql.identifier(key)}`;
27434
27458
  }
27435
27459
  default: {
27436
- return sql`${table6}.${sql.identifier(column6.name)} as ${sql.identifier(key)}`;
27460
+ return sql`${name2} as ${sql.identifier(key)}`;
27437
27461
  }
27438
27462
  }
27439
27463
  }
@@ -32252,6 +32276,9 @@ var init_blob = __esm({
32252
32276
  if (Buffer.isBuffer(value)) {
32253
32277
  return BigInt(value.toString());
32254
32278
  }
32279
+ if (typeof value === "string") {
32280
+ return BigInt(Buffer.from(value, "hex").toString());
32281
+ }
32255
32282
  if (value instanceof ArrayBuffer) {
32256
32283
  const decoder = new TextDecoder();
32257
32284
  return BigInt(decoder.decode(value));
@@ -32284,6 +32311,9 @@ var init_blob = __esm({
32284
32311
  if (Buffer.isBuffer(value)) {
32285
32312
  return JSON.parse(value.toString());
32286
32313
  }
32314
+ if (typeof value === "string") {
32315
+ return JSON.parse(Buffer.from(value, "hex").toString());
32316
+ }
32287
32317
  if (value instanceof ArrayBuffer) {
32288
32318
  const decoder = new TextDecoder();
32289
32319
  return JSON.parse(decoder.decode(value));
@@ -32306,6 +32336,12 @@ var init_blob = __esm({
32306
32336
  };
32307
32337
  __publicField(SQLiteBlobBufferBuilder, _a187, "SQLiteBlobBufferBuilder");
32308
32338
  SQLiteBlobBuffer = class extends (_b125 = SQLiteColumn, _a188 = entityKind, _b125) {
32339
+ mapFromDriverValue(value) {
32340
+ if (typeof value === "string") {
32341
+ return Buffer.from(value, "hex");
32342
+ }
32343
+ return value;
32344
+ }
32309
32345
  getSQLType() {
32310
32346
  return "blob";
32311
32347
  }
@@ -32884,7 +32920,7 @@ var init_dialect2 = __esm({
32884
32920
  key: k,
32885
32921
  field: v
32886
32922
  });
32887
- return sql`${table6}.${this.buildRqbColumn(v, k)}`;
32923
+ return this.buildRqbColumn(table6, v, k);
32888
32924
  }),
32889
32925
  sql`, `
32890
32926
  );
@@ -32922,7 +32958,7 @@ var init_dialect2 = __esm({
32922
32958
  const columnIdentifiers = [];
32923
32959
  const selectedColumns = this.getSelectedTableColumns(table6, params?.columns);
32924
32960
  for (const { column: column6, tsName } of selectedColumns) {
32925
- columnIdentifiers.push(sql`${table6}.${this.buildRqbColumn(column6, tsName)}`);
32961
+ columnIdentifiers.push(this.buildRqbColumn(table6, column6, tsName));
32926
32962
  selection.push({
32927
32963
  key: tsName,
32928
32964
  field: column6
@@ -33472,8 +33508,21 @@ var init_dialect2 = __esm({
33472
33508
  message: `Views with nested selections are not supported by the relational query builder`
33473
33509
  });
33474
33510
  }
33475
- buildRqbColumn(column6, key) {
33476
- return sql`${is(column6, Column2) ? sql.identifier(this.casing.getColumnCasing(column6)) : is(column6, SQL.Aliased) ? sql.identifier(column6.fieldAlias) : isSQLWrapper(column6) ? sql.identifier(key) : this.nestedSelectionerror()} as ${sql.identifier(key)}`;
33511
+ buildRqbColumn(table6, column6, key) {
33512
+ if (is(column6, Column2)) {
33513
+ const name2 = sql`${table6}.${sql.identifier(this.casing.getColumnCasing(column6))}`;
33514
+ switch (column6.columnType) {
33515
+ case "SQLiteBigInt":
33516
+ case "SQLiteBlobJson":
33517
+ case "SQLiteBlobBuffer": {
33518
+ return sql`hex(${name2}) as ${sql.identifier(key)}`;
33519
+ }
33520
+ default: {
33521
+ return sql`${name2} as ${sql.identifier(key)}`;
33522
+ }
33523
+ }
33524
+ }
33525
+ return sql`${table6}.${is(column6, SQL.Aliased) ? sql.identifier(column6.fieldAlias) : isSQLWrapper(column6) ? sql.identifier(key) : this.nestedSelectionerror()} as ${sql.identifier(key)}`;
33477
33526
  }
33478
33527
  buildRelationalQuery({
33479
33528
  tables,
@@ -36917,6 +36966,17 @@ var init_binary = __esm({
36917
36966
  super(...arguments);
36918
36967
  __publicField(this, "length", this.config.length);
36919
36968
  }
36969
+ mapFromDriverValue(value) {
36970
+ if (typeof value === "string")
36971
+ return value;
36972
+ if (Buffer.isBuffer(value))
36973
+ return value.toString();
36974
+ const str = [];
36975
+ for (const v of value) {
36976
+ str.push(v === 49 ? "1" : "0");
36977
+ }
36978
+ return str.join("");
36979
+ }
36920
36980
  getSQLType() {
36921
36981
  return this.length === void 0 ? `binary` : `binary(${this.length})`;
36922
36982
  }
@@ -37230,6 +37290,11 @@ var init_decimal = __esm({
37230
37290
  __publicField(this, "scale", this.config.scale);
37231
37291
  __publicField(this, "unsigned", this.config.unsigned);
37232
37292
  }
37293
+ mapFromDriverValue(value) {
37294
+ if (typeof value === "string")
37295
+ return value;
37296
+ return String(value);
37297
+ }
37233
37298
  getSQLType() {
37234
37299
  let type = "";
37235
37300
  if (this.precision !== void 0 && this.scale !== void 0) {
@@ -37369,6 +37434,12 @@ var init_float = __esm({
37369
37434
  __publicField(this, "scale", this.config.scale);
37370
37435
  __publicField(this, "unsigned", this.config.unsigned);
37371
37436
  }
37437
+ mapFromDriverValue(value) {
37438
+ if (typeof value === "string") {
37439
+ return Number(value);
37440
+ }
37441
+ return value;
37442
+ }
37372
37443
  getSQLType() {
37373
37444
  let type = "";
37374
37445
  if (this.precision !== void 0 && this.scale !== void 0) {
@@ -37882,6 +37953,17 @@ var init_varbinary = __esm({
37882
37953
  super(...arguments);
37883
37954
  __publicField(this, "length", this.config.length);
37884
37955
  }
37956
+ mapFromDriverValue(value) {
37957
+ if (typeof value === "string")
37958
+ return value;
37959
+ if (Buffer.isBuffer(value))
37960
+ return value.toString();
37961
+ const str = [];
37962
+ for (const v of value) {
37963
+ str.push(v === 49 ? "1" : "0");
37964
+ }
37965
+ return str.join("");
37966
+ }
37885
37967
  getSQLType() {
37886
37968
  return this.length === void 0 ? `varbinary` : `varbinary(${this.length})`;
37887
37969
  }
@@ -38427,7 +38509,7 @@ var init_dialect3 = __esm({
38427
38509
  key: k,
38428
38510
  field: v
38429
38511
  });
38430
- return sql`${table6}.${this.buildRqbColumn(v, k)}`;
38512
+ return this.buildRqbColumn(table6, v, k);
38431
38513
  }),
38432
38514
  sql`, `
38433
38515
  );
@@ -38465,7 +38547,7 @@ var init_dialect3 = __esm({
38465
38547
  const columnIdentifiers = [];
38466
38548
  const selectedColumns = this.getSelectedTableColumns(table6, params.columns);
38467
38549
  for (const { column: column6, tsName } of selectedColumns) {
38468
- columnIdentifiers.push(sql`${table6}.${this.buildRqbColumn(column6, tsName)}`);
38550
+ columnIdentifiers.push(this.buildRqbColumn(table6, column6, tsName));
38469
38551
  selection.push({
38470
38552
  key: tsName,
38471
38553
  field: column6
@@ -39286,8 +39368,25 @@ var init_dialect3 = __esm({
39286
39368
  message: `Views with nested selections are not supported by the relational query builder`
39287
39369
  });
39288
39370
  }
39289
- buildRqbColumn(column6, key) {
39290
- return sql`${is(column6, Column2) ? sql.identifier(this.casing.getColumnCasing(column6)) : is(column6, SQL.Aliased) ? sql.identifier(column6.fieldAlias) : isSQLWrapper(column6) ? sql.identifier(key) : this.nestedSelectionerror()} as ${sql.identifier(key)}`;
39371
+ buildRqbColumn(table6, column6, key) {
39372
+ if (is(column6, Column2)) {
39373
+ const name2 = sql`${table6}.${sql.identifier(this.casing.getColumnCasing(column6))}`;
39374
+ switch (column6.columnType) {
39375
+ case "MySqlBinary":
39376
+ case "MySqlVarBinary":
39377
+ case "MySqlTime":
39378
+ case "MySqlDateTimeString":
39379
+ case "MySqlTimestampString":
39380
+ case "MySqlFloat":
39381
+ case "MySqlBigInt64": {
39382
+ return sql`cast(${name2} as char) as ${sql.identifier(key)}`;
39383
+ }
39384
+ default: {
39385
+ return sql`${name2} as ${sql.identifier(key)}`;
39386
+ }
39387
+ }
39388
+ }
39389
+ return sql`${table6}.${is(column6, SQL.Aliased) ? sql.identifier(column6.fieldAlias) : isSQLWrapper(column6) ? sql.identifier(key) : this.nestedSelectionerror()} as ${sql.identifier(key)}`;
39291
39390
  }
39292
39391
  buildRelationalQuery({
39293
39392
  tables,
package/bin.cjs CHANGED
@@ -92669,7 +92669,7 @@ init_utils5();
92669
92669
  var version2 = async () => {
92670
92670
  const { npmVersion } = await ormCoreVersions();
92671
92671
  const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
92672
- const envVersion = "0.30.5-9fd1115";
92672
+ const envVersion = "0.30.5-abfca61";
92673
92673
  const kitVersion = envVersion ? `v${envVersion}` : "--";
92674
92674
  const versions = `drizzle-kit: ${kitVersion}
92675
92675
  ${ormVersion}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-kit",
3
- "version": "0.30.5-9fd1115",
3
+ "version": "0.30.5-abfca61",
4
4
  "homepage": "https://orm.drizzle.team",
5
5
  "keywords": [
6
6
  "drizzle",