drizzle-seed 0.2.0-be0f833 → 0.2.1

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/index.cjs CHANGED
@@ -133327,7 +133327,7 @@ class GenerateStringV2 extends AbstractGenerator {
133327
133327
  uniqueVersionOfGen = GenerateUniqueStringV2;
133328
133328
  init({ count, seed }) {
133329
133329
  super.init({ count, seed });
133330
- let minStringLength = 8;
133330
+ let minStringLength = 7;
133331
133331
  let maxStringLength = 20;
133332
133332
  if (this.stringLength !== undefined) {
133333
133333
  maxStringLength = this.stringLength;
@@ -133362,7 +133362,7 @@ class GenerateUniqueStringV2 extends AbstractGenerator {
133362
133362
  isUnique = true;
133363
133363
  init({ seed, count }) {
133364
133364
  const rng = prand.xoroshiro128plus(seed);
133365
- let minStringLength = 8;
133365
+ let minStringLength = 7;
133366
133366
  let maxStringLength = 20;
133367
133367
  // TODO: revise later
133368
133368
  if (this.stringLength !== undefined) {
@@ -134386,13 +134386,13 @@ class SeedService {
134386
134386
  if (arrayGen !== undefined) {
134387
134387
  columnPossibleGenerator.generator = arrayGen;
134388
134388
  }
134389
+ columnPossibleGenerator.generator.isUnique = col.isUnique;
134389
134390
  const uniqueGen = columnPossibleGenerator.generator.replaceIfUnique();
134390
134391
  if (uniqueGen !== undefined) {
134391
134392
  columnPossibleGenerator.generator = uniqueGen;
134392
134393
  }
134393
134394
  // selecting version of generator
134394
134395
  columnPossibleGenerator.generator = this.selectVersionOfGenerator(columnPossibleGenerator.generator);
134395
- columnPossibleGenerator.generator.isUnique = col.isUnique;
134396
134396
  // TODO: for now only GenerateValuesFromArray support notNull property
134397
134397
  columnPossibleGenerator.generator.notNull = col.notNull;
134398
134398
  columnPossibleGenerator.generator.dataType = col.dataType;
@@ -134420,6 +134420,8 @@ class SeedService {
134420
134420
  const newGenerator = new generatorConstructor(generator.params);
134421
134421
  newGenerator.baseColumnDataType = generator.baseColumnDataType;
134422
134422
  newGenerator.isUnique = generator.isUnique;
134423
+ // TODO: for now only GenerateValuesFromArray support notNull property
134424
+ newGenerator.notNull = generator.notNull;
134423
134425
  newGenerator.dataType = generator.dataType;
134424
134426
  newGenerator.stringLength = generator.stringLength;
134425
134427
  return newGenerator;
@@ -135804,7 +135806,8 @@ const getMySqlInfo = (schema) => {
135804
135806
  typeParams['scale'] = Number(match[2]);
135805
135807
  }
135806
135808
  }
135807
- else if (sqlType.startsWith('varchar')
135809
+ else if (sqlType.startsWith('char')
135810
+ || sqlType.startsWith('varchar')
135808
135811
  || sqlType.startsWith('binary')
135809
135812
  || sqlType.startsWith('varbinary')) {
135810
135813
  const match = sqlType.match(/\((\d+)\)/);
@@ -135923,12 +135926,32 @@ const getSqliteInfo = (schema) => {
135923
135926
  tableRelations[dbToTsTableNamesMap[tableConfig.name]] = [];
135924
135927
  }
135925
135928
  tableRelations[dbToTsTableNamesMap[tableConfig.name]].push(...newRelations);
135929
+ const getTypeParams = (sqlType) => {
135930
+ // get type params and set only type
135931
+ const typeParams = {};
135932
+ if (sqlType.startsWith('decimal')) {
135933
+ const match = sqlType.match(/\((\d+), *(\d+)\)/);
135934
+ if (match) {
135935
+ typeParams['precision'] = Number(match[1]);
135936
+ typeParams['scale'] = Number(match[2]);
135937
+ }
135938
+ }
135939
+ else if (sqlType.startsWith('char')
135940
+ || sqlType.startsWith('varchar')
135941
+ || sqlType.startsWith('text')) {
135942
+ const match = sqlType.match(/\((\d+)\)/);
135943
+ if (match) {
135944
+ typeParams['length'] = Number(match[1]);
135945
+ }
135946
+ }
135947
+ return typeParams;
135948
+ };
135926
135949
  tables.push({
135927
135950
  name: dbToTsTableNamesMap[tableConfig.name],
135928
135951
  columns: tableConfig.columns.map((column) => ({
135929
135952
  name: dbToTsColumnNamesMap[column.name],
135930
135953
  columnType: column.getSQLType(),
135931
- typeParams: {},
135954
+ typeParams: getTypeParams(column.getSQLType()),
135932
135955
  dataType: column.dataType,
135933
135956
  hasDefault: column.hasDefault,
135934
135957
  default: column.default,