drizzle-kit 0.30.1-5734f71 → 0.30.1-57eb6bd

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 +45 -32
  2. package/api.mjs +45 -32
  3. package/bin.cjs +1 -1
  4. package/package.json +1 -1
package/api.js CHANGED
@@ -22255,7 +22255,7 @@ var init_sql = __esm({
22255
22255
  const schemaName = chunk[Table2.Symbol.Schema];
22256
22256
  const tableName = chunk[Table2.Symbol.Name];
22257
22257
  return {
22258
- sql: schemaName === void 0 ? escapeName(tableName) : escapeName(schemaName) + "." + escapeName(tableName),
22258
+ sql: schemaName === void 0 || chunk[Table2.Symbol.IsAlias] ? escapeName(tableName) : escapeName(schemaName) + "." + escapeName(tableName),
22259
22259
  params: []
22260
22260
  };
22261
22261
  }
@@ -25053,23 +25053,20 @@ function relationExtrasToSQL(table5, extras) {
25053
25053
  selection
25054
25054
  };
25055
25055
  }
25056
- function getTableSql(table5) {
25057
- return sql`${sql`${sql`${sql.identifier(table5[Schema] ?? "")}.`.if(!table5[IsAlias] && table5[Schema])}`}${table5}`;
25058
- }
25059
25056
  function relationToSQL(relation, sourceTable, targetTable, throughTable) {
25060
25057
  if (relation.through) {
25061
25058
  const outerColumnWhere = relation.sourceColumns.map((s, i) => {
25062
25059
  const t = relation.through.source[i];
25063
25060
  return eq(
25064
- sql`${getTableSql(sourceTable)}.${sql.identifier(s.name)}`,
25065
- sql`${getTableSql(throughTable)}.${sql.identifier(t.name)}`
25061
+ sql`${sourceTable}.${sql.identifier(s.name)}`,
25062
+ sql`${throughTable}.${sql.identifier(t.name)}`
25066
25063
  );
25067
25064
  });
25068
25065
  const innerColumnWhere = relation.targetColumns.map((s, i) => {
25069
25066
  const t = relation.through.target[i];
25070
25067
  return eq(
25071
- sql`${getTableSql(throughTable)}.${sql.identifier(t.name)}`,
25072
- sql`${getTableSql(targetTable)}.${sql.identifier(s.name)}`
25068
+ sql`${throughTable}.${sql.identifier(t.name)}`,
25069
+ sql`${targetTable}.${sql.identifier(s.name)}`
25073
25070
  );
25074
25071
  });
25075
25072
  return {
@@ -25085,8 +25082,8 @@ function relationToSQL(relation, sourceTable, targetTable, throughTable) {
25085
25082
  const columnWhere = relation.sourceColumns.map((s, i) => {
25086
25083
  const t = relation.targetColumns[i];
25087
25084
  return eq(
25088
- sql`${getTableSql(sourceTable)}.${sql.identifier(s.name)}`,
25089
- sql`${getTableSql(targetTable)}.${sql.identifier(t.name)}`
25085
+ sql`${sourceTable}.${sql.identifier(s.name)}`,
25086
+ sql`${targetTable}.${sql.identifier(t.name)}`
25090
25087
  );
25091
25088
  });
25092
25089
  const fullWhere = and(
@@ -34391,9 +34388,10 @@ var init_query4 = __esm({
34391
34388
  init_entity();
34392
34389
  init_query_promise();
34393
34390
  init_relations();
34391
+ init_sql();
34394
34392
  _a224 = entityKind;
34395
34393
  RelationalQueryBuilder2 = class {
34396
- constructor(mode, tables, schema5, tableNamesMap, table5, tableConfig, dialect6, session) {
34394
+ constructor(mode, tables, schema5, tableNamesMap, table5, tableConfig, dialect6, session, rowMode) {
34397
34395
  this.mode = mode;
34398
34396
  this.tables = tables;
34399
34397
  this.schema = schema5;
@@ -34402,6 +34400,7 @@ var init_query4 = __esm({
34402
34400
  this.tableConfig = tableConfig;
34403
34401
  this.dialect = dialect6;
34404
34402
  this.session = session;
34403
+ this.rowMode = rowMode;
34405
34404
  }
34406
34405
  findMany(config) {
34407
34406
  return this.mode === "sync" ? new SQLiteSyncRelationalQuery2(
@@ -34413,7 +34412,8 @@ var init_query4 = __esm({
34413
34412
  this.dialect,
34414
34413
  this.session,
34415
34414
  config ?? true,
34416
- "many"
34415
+ "many",
34416
+ this.rowMode
34417
34417
  ) : new SQLiteRelationalQuery2(
34418
34418
  this.tables,
34419
34419
  this.schema,
@@ -34423,7 +34423,8 @@ var init_query4 = __esm({
34423
34423
  this.dialect,
34424
34424
  this.session,
34425
34425
  config ?? true,
34426
- "many"
34426
+ "many",
34427
+ this.rowMode
34427
34428
  );
34428
34429
  }
34429
34430
  findFirst(config) {
@@ -34436,7 +34437,8 @@ var init_query4 = __esm({
34436
34437
  this.dialect,
34437
34438
  this.session,
34438
34439
  config ?? true,
34439
- "first"
34440
+ "first",
34441
+ this.rowMode
34440
34442
  ) : new SQLiteRelationalQuery2(
34441
34443
  this.tables,
34442
34444
  this.schema,
@@ -34446,13 +34448,14 @@ var init_query4 = __esm({
34446
34448
  this.dialect,
34447
34449
  this.session,
34448
34450
  config ?? true,
34449
- "first"
34451
+ "first",
34452
+ this.rowMode
34450
34453
  );
34451
34454
  }
34452
34455
  };
34453
34456
  __publicField(RelationalQueryBuilder2, _a224, "SQLiteAsyncRelationalQueryBuilderV2");
34454
34457
  SQLiteRelationalQuery2 = class extends (_b156 = QueryPromise, _a225 = entityKind, _b156) {
34455
- constructor(tables, schema5, tableNamesMap, table5, tableConfig, dialect6, session, config, mode) {
34458
+ constructor(tables, schema5, tableNamesMap, table5, tableConfig, dialect6, session, config, mode, rowMode) {
34456
34459
  super();
34457
34460
  /** @internal */
34458
34461
  __publicField(this, "mode");
@@ -34465,6 +34468,7 @@ var init_query4 = __esm({
34465
34468
  this.dialect = dialect6;
34466
34469
  this.session = session;
34467
34470
  this.config = config;
34471
+ this.rowMode = rowMode;
34468
34472
  this.mode = mode;
34469
34473
  this.table = table5;
34470
34474
  }
@@ -34489,7 +34493,7 @@ var init_query4 = __esm({
34489
34493
  void 0,
34490
34494
  this.mode === "first" ? "get" : "all",
34491
34495
  (rawRows, mapColumnValue) => {
34492
- const rows = rawRows.map((row) => mapRelationalRow(row, query.selection, mapColumnValue, true));
34496
+ const rows = rawRows.map((row) => mapRelationalRow(row, query.selection, mapColumnValue, !this.rowMode));
34493
34497
  if (this.mode === "first") {
34494
34498
  return rows[0];
34495
34499
  }
@@ -34501,15 +34505,26 @@ var init_query4 = __esm({
34501
34505
  return this._prepare(false);
34502
34506
  }
34503
34507
  _getQuery() {
34504
- return this.dialect.buildRelationalQuery({
34508
+ const query = this.dialect.buildRelationalQuery({
34505
34509
  schema: this.schema,
34506
34510
  tableNamesMap: this.tableNamesMap,
34507
34511
  table: this.table,
34508
34512
  tableConfig: this.tableConfig,
34509
34513
  queryConfig: this.config,
34510
34514
  tables: this.tables,
34511
- mode: this.mode
34515
+ mode: this.mode,
34516
+ isNested: this.rowMode
34512
34517
  });
34518
+ if (this.rowMode) {
34519
+ const jsonColumns = sql.join(
34520
+ query.selection.map((s) => {
34521
+ return sql`${sql.raw(this.dialect.escapeString(s.key))}, ${s.selection ? sql`jsonb(${sql.identifier(s.key)})` : sql.identifier(s.key)}`;
34522
+ }),
34523
+ sql`, `
34524
+ );
34525
+ query.sql = sql`select json_object(${jsonColumns}) as ${sql.identifier("r")} from (${query.sql}) as ${sql.identifier("t")}`;
34526
+ }
34527
+ return query;
34513
34528
  }
34514
34529
  _toSQL() {
34515
34530
  const query = this._getQuery();
@@ -34592,7 +34607,7 @@ var init_db2 = __esm({
34592
34607
  init_raw2();
34593
34608
  _a228 = entityKind;
34594
34609
  BaseSQLiteDatabase = class {
34595
- constructor(resultKind, dialect6, session, relations, _schema) {
34610
+ constructor(resultKind, dialect6, session, relations, _schema, rowModeRQB) {
34596
34611
  /** @deprecated */
34597
34612
  __publicField(this, "_query");
34598
34613
  // TO-DO: Figure out how to pass DrizzleTypeError without breaking withReplicas
@@ -34600,6 +34615,7 @@ var init_db2 = __esm({
34600
34615
  this.resultKind = resultKind;
34601
34616
  this.dialect = dialect6;
34602
34617
  this.session = session;
34618
+ this.rowModeRQB = rowModeRQB;
34603
34619
  const rel = relations ?? {};
34604
34620
  this._ = _schema ? {
34605
34621
  schema: _schema.schema,
@@ -34639,7 +34655,8 @@ var init_db2 = __esm({
34639
34655
  relation.table,
34640
34656
  relation,
34641
34657
  dialect6,
34642
- session
34658
+ session,
34659
+ rowModeRQB
34643
34660
  );
34644
34661
  }
34645
34662
  }
@@ -35105,8 +35122,8 @@ var init_session2 = __esm({
35105
35122
  };
35106
35123
  __publicField(SQLiteSession, _a236, "SQLiteSession");
35107
35124
  SQLiteTransaction = class extends (_b160 = BaseSQLiteDatabase, _a237 = entityKind, _b160) {
35108
- constructor(resultType, dialect6, session, relations, schema5, nestedIndex = 0) {
35109
- super(resultType, dialect6, session, relations, schema5);
35125
+ constructor(resultType, dialect6, session, relations, schema5, nestedIndex = 0, rowModeRQB) {
35126
+ super(resultType, dialect6, session, relations, schema5, rowModeRQB);
35110
35127
  this.relations = relations;
35111
35128
  this.schema = schema5;
35112
35129
  this.nestedIndex = nestedIndex;
@@ -37885,15 +37902,11 @@ var init_dialect3 = __esm({
37885
37902
  const columnIdentifiers = [];
37886
37903
  const selectedColumns = this.getSelectedTableColumns(table5, params?.columns);
37887
37904
  for (const column5 of selectedColumns) {
37888
- columnIdentifiers.push(
37889
- sql`${table5[column5.tsName]} as ${sql.identifier(column5.tsName)}`
37890
- );
37891
- selection.push(
37892
- {
37893
- key: column5.tsName,
37894
- field: column5.column
37895
- }
37896
- );
37905
+ columnIdentifiers.push(sql`${column5.column} as ${sql.identifier(column5.tsName)}`);
37906
+ selection.push({
37907
+ key: column5.tsName,
37908
+ field: column5.column
37909
+ });
37897
37910
  }
37898
37911
  return columnIdentifiers.length ? sql.join(columnIdentifiers, sql`, `) : void 0;
37899
37912
  })() : this.unwrapAllColumns(table5, selection));
package/api.mjs CHANGED
@@ -22260,7 +22260,7 @@ var init_sql = __esm({
22260
22260
  const schemaName = chunk[Table2.Symbol.Schema];
22261
22261
  const tableName = chunk[Table2.Symbol.Name];
22262
22262
  return {
22263
- sql: schemaName === void 0 ? escapeName(tableName) : escapeName(schemaName) + "." + escapeName(tableName),
22263
+ sql: schemaName === void 0 || chunk[Table2.Symbol.IsAlias] ? escapeName(tableName) : escapeName(schemaName) + "." + escapeName(tableName),
22264
22264
  params: []
22265
22265
  };
22266
22266
  }
@@ -25058,23 +25058,20 @@ function relationExtrasToSQL(table5, extras) {
25058
25058
  selection
25059
25059
  };
25060
25060
  }
25061
- function getTableSql(table5) {
25062
- return sql`${sql`${sql`${sql.identifier(table5[Schema] ?? "")}.`.if(!table5[IsAlias] && table5[Schema])}`}${table5}`;
25063
- }
25064
25061
  function relationToSQL(relation, sourceTable, targetTable, throughTable) {
25065
25062
  if (relation.through) {
25066
25063
  const outerColumnWhere = relation.sourceColumns.map((s, i) => {
25067
25064
  const t = relation.through.source[i];
25068
25065
  return eq(
25069
- sql`${getTableSql(sourceTable)}.${sql.identifier(s.name)}`,
25070
- sql`${getTableSql(throughTable)}.${sql.identifier(t.name)}`
25066
+ sql`${sourceTable}.${sql.identifier(s.name)}`,
25067
+ sql`${throughTable}.${sql.identifier(t.name)}`
25071
25068
  );
25072
25069
  });
25073
25070
  const innerColumnWhere = relation.targetColumns.map((s, i) => {
25074
25071
  const t = relation.through.target[i];
25075
25072
  return eq(
25076
- sql`${getTableSql(throughTable)}.${sql.identifier(t.name)}`,
25077
- sql`${getTableSql(targetTable)}.${sql.identifier(s.name)}`
25073
+ sql`${throughTable}.${sql.identifier(t.name)}`,
25074
+ sql`${targetTable}.${sql.identifier(s.name)}`
25078
25075
  );
25079
25076
  });
25080
25077
  return {
@@ -25090,8 +25087,8 @@ function relationToSQL(relation, sourceTable, targetTable, throughTable) {
25090
25087
  const columnWhere = relation.sourceColumns.map((s, i) => {
25091
25088
  const t = relation.targetColumns[i];
25092
25089
  return eq(
25093
- sql`${getTableSql(sourceTable)}.${sql.identifier(s.name)}`,
25094
- sql`${getTableSql(targetTable)}.${sql.identifier(t.name)}`
25090
+ sql`${sourceTable}.${sql.identifier(s.name)}`,
25091
+ sql`${targetTable}.${sql.identifier(t.name)}`
25095
25092
  );
25096
25093
  });
25097
25094
  const fullWhere = and(
@@ -34396,9 +34393,10 @@ var init_query4 = __esm({
34396
34393
  init_entity();
34397
34394
  init_query_promise();
34398
34395
  init_relations();
34396
+ init_sql();
34399
34397
  _a224 = entityKind;
34400
34398
  RelationalQueryBuilder2 = class {
34401
- constructor(mode, tables, schema5, tableNamesMap, table5, tableConfig, dialect6, session) {
34399
+ constructor(mode, tables, schema5, tableNamesMap, table5, tableConfig, dialect6, session, rowMode) {
34402
34400
  this.mode = mode;
34403
34401
  this.tables = tables;
34404
34402
  this.schema = schema5;
@@ -34407,6 +34405,7 @@ var init_query4 = __esm({
34407
34405
  this.tableConfig = tableConfig;
34408
34406
  this.dialect = dialect6;
34409
34407
  this.session = session;
34408
+ this.rowMode = rowMode;
34410
34409
  }
34411
34410
  findMany(config) {
34412
34411
  return this.mode === "sync" ? new SQLiteSyncRelationalQuery2(
@@ -34418,7 +34417,8 @@ var init_query4 = __esm({
34418
34417
  this.dialect,
34419
34418
  this.session,
34420
34419
  config ?? true,
34421
- "many"
34420
+ "many",
34421
+ this.rowMode
34422
34422
  ) : new SQLiteRelationalQuery2(
34423
34423
  this.tables,
34424
34424
  this.schema,
@@ -34428,7 +34428,8 @@ var init_query4 = __esm({
34428
34428
  this.dialect,
34429
34429
  this.session,
34430
34430
  config ?? true,
34431
- "many"
34431
+ "many",
34432
+ this.rowMode
34432
34433
  );
34433
34434
  }
34434
34435
  findFirst(config) {
@@ -34441,7 +34442,8 @@ var init_query4 = __esm({
34441
34442
  this.dialect,
34442
34443
  this.session,
34443
34444
  config ?? true,
34444
- "first"
34445
+ "first",
34446
+ this.rowMode
34445
34447
  ) : new SQLiteRelationalQuery2(
34446
34448
  this.tables,
34447
34449
  this.schema,
@@ -34451,13 +34453,14 @@ var init_query4 = __esm({
34451
34453
  this.dialect,
34452
34454
  this.session,
34453
34455
  config ?? true,
34454
- "first"
34456
+ "first",
34457
+ this.rowMode
34455
34458
  );
34456
34459
  }
34457
34460
  };
34458
34461
  __publicField(RelationalQueryBuilder2, _a224, "SQLiteAsyncRelationalQueryBuilderV2");
34459
34462
  SQLiteRelationalQuery2 = class extends (_b156 = QueryPromise, _a225 = entityKind, _b156) {
34460
- constructor(tables, schema5, tableNamesMap, table5, tableConfig, dialect6, session, config, mode) {
34463
+ constructor(tables, schema5, tableNamesMap, table5, tableConfig, dialect6, session, config, mode, rowMode) {
34461
34464
  super();
34462
34465
  /** @internal */
34463
34466
  __publicField(this, "mode");
@@ -34470,6 +34473,7 @@ var init_query4 = __esm({
34470
34473
  this.dialect = dialect6;
34471
34474
  this.session = session;
34472
34475
  this.config = config;
34476
+ this.rowMode = rowMode;
34473
34477
  this.mode = mode;
34474
34478
  this.table = table5;
34475
34479
  }
@@ -34494,7 +34498,7 @@ var init_query4 = __esm({
34494
34498
  void 0,
34495
34499
  this.mode === "first" ? "get" : "all",
34496
34500
  (rawRows, mapColumnValue) => {
34497
- const rows = rawRows.map((row) => mapRelationalRow(row, query.selection, mapColumnValue, true));
34501
+ const rows = rawRows.map((row) => mapRelationalRow(row, query.selection, mapColumnValue, !this.rowMode));
34498
34502
  if (this.mode === "first") {
34499
34503
  return rows[0];
34500
34504
  }
@@ -34506,15 +34510,26 @@ var init_query4 = __esm({
34506
34510
  return this._prepare(false);
34507
34511
  }
34508
34512
  _getQuery() {
34509
- return this.dialect.buildRelationalQuery({
34513
+ const query = this.dialect.buildRelationalQuery({
34510
34514
  schema: this.schema,
34511
34515
  tableNamesMap: this.tableNamesMap,
34512
34516
  table: this.table,
34513
34517
  tableConfig: this.tableConfig,
34514
34518
  queryConfig: this.config,
34515
34519
  tables: this.tables,
34516
- mode: this.mode
34520
+ mode: this.mode,
34521
+ isNested: this.rowMode
34517
34522
  });
34523
+ if (this.rowMode) {
34524
+ const jsonColumns = sql.join(
34525
+ query.selection.map((s) => {
34526
+ return sql`${sql.raw(this.dialect.escapeString(s.key))}, ${s.selection ? sql`jsonb(${sql.identifier(s.key)})` : sql.identifier(s.key)}`;
34527
+ }),
34528
+ sql`, `
34529
+ );
34530
+ query.sql = sql`select json_object(${jsonColumns}) as ${sql.identifier("r")} from (${query.sql}) as ${sql.identifier("t")}`;
34531
+ }
34532
+ return query;
34518
34533
  }
34519
34534
  _toSQL() {
34520
34535
  const query = this._getQuery();
@@ -34597,7 +34612,7 @@ var init_db2 = __esm({
34597
34612
  init_raw2();
34598
34613
  _a228 = entityKind;
34599
34614
  BaseSQLiteDatabase = class {
34600
- constructor(resultKind, dialect6, session, relations, _schema) {
34615
+ constructor(resultKind, dialect6, session, relations, _schema, rowModeRQB) {
34601
34616
  /** @deprecated */
34602
34617
  __publicField(this, "_query");
34603
34618
  // TO-DO: Figure out how to pass DrizzleTypeError without breaking withReplicas
@@ -34605,6 +34620,7 @@ var init_db2 = __esm({
34605
34620
  this.resultKind = resultKind;
34606
34621
  this.dialect = dialect6;
34607
34622
  this.session = session;
34623
+ this.rowModeRQB = rowModeRQB;
34608
34624
  const rel = relations ?? {};
34609
34625
  this._ = _schema ? {
34610
34626
  schema: _schema.schema,
@@ -34644,7 +34660,8 @@ var init_db2 = __esm({
34644
34660
  relation.table,
34645
34661
  relation,
34646
34662
  dialect6,
34647
- session
34663
+ session,
34664
+ rowModeRQB
34648
34665
  );
34649
34666
  }
34650
34667
  }
@@ -35110,8 +35127,8 @@ var init_session2 = __esm({
35110
35127
  };
35111
35128
  __publicField(SQLiteSession, _a236, "SQLiteSession");
35112
35129
  SQLiteTransaction = class extends (_b160 = BaseSQLiteDatabase, _a237 = entityKind, _b160) {
35113
- constructor(resultType, dialect6, session, relations, schema5, nestedIndex = 0) {
35114
- super(resultType, dialect6, session, relations, schema5);
35130
+ constructor(resultType, dialect6, session, relations, schema5, nestedIndex = 0, rowModeRQB) {
35131
+ super(resultType, dialect6, session, relations, schema5, rowModeRQB);
35115
35132
  this.relations = relations;
35116
35133
  this.schema = schema5;
35117
35134
  this.nestedIndex = nestedIndex;
@@ -37890,15 +37907,11 @@ var init_dialect3 = __esm({
37890
37907
  const columnIdentifiers = [];
37891
37908
  const selectedColumns = this.getSelectedTableColumns(table5, params?.columns);
37892
37909
  for (const column5 of selectedColumns) {
37893
- columnIdentifiers.push(
37894
- sql`${table5[column5.tsName]} as ${sql.identifier(column5.tsName)}`
37895
- );
37896
- selection.push(
37897
- {
37898
- key: column5.tsName,
37899
- field: column5.column
37900
- }
37901
- );
37910
+ columnIdentifiers.push(sql`${column5.column} as ${sql.identifier(column5.tsName)}`);
37911
+ selection.push({
37912
+ key: column5.tsName,
37913
+ field: column5.column
37914
+ });
37902
37915
  }
37903
37916
  return columnIdentifiers.length ? sql.join(columnIdentifiers, sql`, `) : void 0;
37904
37917
  })() : this.unwrapAllColumns(table5, selection));
package/bin.cjs CHANGED
@@ -92611,7 +92611,7 @@ init_utils5();
92611
92611
  var version2 = async () => {
92612
92612
  const { npmVersion } = await ormCoreVersions();
92613
92613
  const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
92614
- const envVersion = "0.30.1-5734f71";
92614
+ const envVersion = "0.30.1-57eb6bd";
92615
92615
  const kitVersion = envVersion ? `v${envVersion}` : "--";
92616
92616
  const versions = `drizzle-kit: ${kitVersion}
92617
92617
  ${ormVersion}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-kit",
3
- "version": "0.30.1-5734f71",
3
+ "version": "0.30.1-57eb6bd",
4
4
  "homepage": "https://orm.drizzle.team",
5
5
  "keywords": [
6
6
  "drizzle",