bun-query-builder 0.2.8 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin/cli.js CHANGED
@@ -18772,7 +18772,7 @@ class SQLiteDriver {
18772
18772
  var init_sqlite = () => {};
18773
18773
 
18774
18774
  // src/drivers/index.ts
18775
- function getDialectDriver(dialect) {
18775
+ function getDialectDriver(dialect, options = {}) {
18776
18776
  switch (dialect) {
18777
18777
  case "postgres":
18778
18778
  return new PostgresDriver;
@@ -18781,7 +18781,7 @@ function getDialectDriver(dialect) {
18781
18781
  case "singlestore":
18782
18782
  return new SingleStoreDriver;
18783
18783
  case "vitess":
18784
- return new VitessDriver(config5.vitess?.sharded ?? true);
18784
+ return new VitessDriver(options.vitessSharded ?? config5.vitess?.sharded ?? true);
18785
18785
  case "sqlite":
18786
18786
  return new SQLiteDriver;
18787
18787
  default:
@@ -18941,7 +18941,7 @@ async function generateMigration(dir, opts = {}) {
18941
18941
  const dialect = opts.dialect || config5.dialect || "postgres";
18942
18942
  const workspaceRoot = getWorkspaceRoot();
18943
18943
  const models = await loadModels({ modelsDir: dir });
18944
- const plan = buildMigrationPlan2(models, { dialect });
18944
+ const plan = buildMigrationPlan2(models, { dialect, vitessSharded: opts.vitessSharded });
18945
18945
  let previous;
18946
18946
  let reconciledFromDatabase = false;
18947
18947
  if (!opts.full) {
@@ -28561,6 +28561,11 @@ function buildMigrationPlan2(models, options) {
28561
28561
  let enumValues;
28562
28562
  const isPk = attrName === primaryKey;
28563
28563
  inferred = normalizeAttributeType(attr.type) ?? detectTypeFromValidationRule(attr.validation?.rule);
28564
+ if (inferred === "string") {
28565
+ const maxLength = extractMaxFromRules(attr.validation?.rule);
28566
+ if (maxLength && maxLength > 255)
28567
+ inferred = "text";
28568
+ }
28564
28569
  if (!inferred || inferred === "enum") {
28565
28570
  const enumVals = detectEnumFromValidationRule(attr.validation?.rule);
28566
28571
  if (enumVals && enumVals.length > 0) {
@@ -28874,7 +28879,7 @@ function buildMigrationPlan2(models, options) {
28874
28879
  ensureTable({ table: pivotTable, columns: cols, indexes: idx });
28875
28880
  }
28876
28881
  }
28877
- return { dialect: options.dialect, tables };
28882
+ return { dialect: options.dialect, vitessSharded: options.vitessSharded, tables };
28878
28883
  }
28879
28884
  function generateSql(plan, opts = {}) {
28880
28885
  migrationCounter = 0;
@@ -28885,7 +28890,7 @@ function generateSql(plan, opts = {}) {
28885
28890
  useDeterministicNames = true;
28886
28891
  const emit = opts.dryRun ? () => false : createMigrationFile;
28887
28892
  const statements = [];
28888
- const driver = getDialectDriver(plan.dialect);
28893
+ const driver = getDialectDriver(plan.dialect, { vitessSharded: plan.vitessSharded });
28889
28894
  const { tables, deferredForeignKeys } = orderTablesForCreate(plan.tables, plan.dialect);
28890
28895
  for (const [tableIndex, originalTable] of tables.entries()) {
28891
28896
  const t2 = {
@@ -29174,7 +29179,7 @@ function generateDiffOperations(previous, next, opts = {}) {
29174
29179
  useDeterministicNames = false;
29175
29180
  const chunks = [];
29176
29181
  const operations = [];
29177
- const driver = getDialectDriver(next.dialect);
29182
+ const driver = getDialectDriver(next.dialect, { vitessSharded: next.vitessSharded });
29178
29183
  const dialect = next.dialect;
29179
29184
  const prevTables = mapTablesByName(previous.tables);
29180
29185
  const nextTables = mapTablesByName(next.tables);
@@ -31531,7 +31536,7 @@ function getPrefix() {
31531
31536
  }
31532
31537
  var prefix = getPrefix();
31533
31538
  // package.json
31534
- var version2 = "0.2.8";
31539
+ var version2 = "0.2.10";
31535
31540
 
31536
31541
  // bin/cli.ts
31537
31542
  init_actions();
@@ -28,7 +28,7 @@ export type {
28
28
  DynamoDBUpdateItemParams,
29
29
  SingleTableEntityMapping,
30
30
  } from './dynamodb';
31
- export declare function getDialectDriver(dialect: SupportedDialect): DialectDriver;
31
+ export declare function getDialectDriver(dialect: SupportedDialect, options?: { vitessSharded?: boolean }): DialectDriver;
32
32
  export { MySQLDriver } from './mysql';
33
33
  export { PostgresDriver } from './postgres';
34
34
  export { SingleStoreDriver } from './singlestore';
@@ -105,6 +105,7 @@ export declare interface TablePlan {
105
105
  }
106
106
  export declare interface MigrationPlan {
107
107
  dialect: SupportedDialect
108
+ vitessSharded?: boolean
108
109
  tables: TablePlan[]
109
110
  }
110
111
  /**
@@ -142,6 +143,7 @@ export declare interface DiffResult {
142
143
  }
143
144
  export declare interface InferenceOptions {
144
145
  dialect: SupportedDialect
146
+ vitessSharded?: boolean
145
147
  }
146
148
  export declare interface DiffOptions {
147
149
  applyRenames?: boolean
package/dist/src/index.js CHANGED
@@ -18771,7 +18771,7 @@ class SQLiteDriver {
18771
18771
  var init_sqlite = () => {};
18772
18772
 
18773
18773
  // src/drivers/index.ts
18774
- function getDialectDriver(dialect) {
18774
+ function getDialectDriver(dialect, options = {}) {
18775
18775
  switch (dialect) {
18776
18776
  case "postgres":
18777
18777
  return new PostgresDriver;
@@ -18780,7 +18780,7 @@ function getDialectDriver(dialect) {
18780
18780
  case "singlestore":
18781
18781
  return new SingleStoreDriver;
18782
18782
  case "vitess":
18783
- return new VitessDriver(config5.vitess?.sharded ?? true);
18783
+ return new VitessDriver(options.vitessSharded ?? config5.vitess?.sharded ?? true);
18784
18784
  case "sqlite":
18785
18785
  return new SQLiteDriver;
18786
18786
  default:
@@ -18940,7 +18940,7 @@ async function generateMigration(dir, opts = {}) {
18940
18940
  const dialect = opts.dialect || config5.dialect || "postgres";
18941
18941
  const workspaceRoot = getWorkspaceRoot();
18942
18942
  const models = await loadModels({ modelsDir: dir });
18943
- const plan = buildMigrationPlan2(models, { dialect });
18943
+ const plan = buildMigrationPlan2(models, { dialect, vitessSharded: opts.vitessSharded });
18944
18944
  let previous;
18945
18945
  let reconciledFromDatabase = false;
18946
18946
  if (!opts.full) {
@@ -28560,6 +28560,11 @@ function buildMigrationPlan2(models, options) {
28560
28560
  let enumValues;
28561
28561
  const isPk = attrName === primaryKey;
28562
28562
  inferred = normalizeAttributeType(attr.type) ?? detectTypeFromValidationRule(attr.validation?.rule);
28563
+ if (inferred === "string") {
28564
+ const maxLength = extractMaxFromRules(attr.validation?.rule);
28565
+ if (maxLength && maxLength > 255)
28566
+ inferred = "text";
28567
+ }
28563
28568
  if (!inferred || inferred === "enum") {
28564
28569
  const enumVals = detectEnumFromValidationRule(attr.validation?.rule);
28565
28570
  if (enumVals && enumVals.length > 0) {
@@ -28873,7 +28878,7 @@ function buildMigrationPlan2(models, options) {
28873
28878
  ensureTable({ table: pivotTable, columns: cols, indexes: idx });
28874
28879
  }
28875
28880
  }
28876
- return { dialect: options.dialect, tables };
28881
+ return { dialect: options.dialect, vitessSharded: options.vitessSharded, tables };
28877
28882
  }
28878
28883
  function generateSql(plan, opts = {}) {
28879
28884
  migrationCounter = 0;
@@ -28884,7 +28889,7 @@ function generateSql(plan, opts = {}) {
28884
28889
  useDeterministicNames = true;
28885
28890
  const emit = opts.dryRun ? () => false : createMigrationFile;
28886
28891
  const statements = [];
28887
- const driver = getDialectDriver(plan.dialect);
28892
+ const driver = getDialectDriver(plan.dialect, { vitessSharded: plan.vitessSharded });
28888
28893
  const { tables, deferredForeignKeys } = orderTablesForCreate(plan.tables, plan.dialect);
28889
28894
  for (const [tableIndex, originalTable] of tables.entries()) {
28890
28895
  const t2 = {
@@ -29173,7 +29178,7 @@ function generateDiffOperations(previous, next, opts = {}) {
29173
29178
  useDeterministicNames = false;
29174
29179
  const chunks = [];
29175
29180
  const operations = [];
29176
- const driver = getDialectDriver(next.dialect);
29181
+ const driver = getDialectDriver(next.dialect, { vitessSharded: next.vitessSharded });
29177
29182
  const dialect = next.dialect;
29178
29183
  const prevTables = mapTablesByName(previous.tables);
29179
29184
  const nextTables = mapTablesByName(next.tables);
package/dist/types.d.ts CHANGED
@@ -271,6 +271,7 @@ export declare interface IntrospectOptions {
271
271
  }
272
272
  export declare interface MigrateOptions {
273
273
  dialect?: SupportedDialect
274
+ vitessSharded?: boolean
274
275
  state?: string
275
276
  apply?: boolean
276
277
  full?: boolean
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bun-query-builder",
3
3
  "type": "module",
4
- "version": "0.2.8",
4
+ "version": "0.2.10",
5
5
  "description": "A simple yet performant query builder for TypeScript. Built with Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",