orchid-orm 1.25.1 → 1.25.3

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.
@@ -2,8 +2,8 @@ import { promptSelect, colors, getSchemaAndTableFromName, getDbTableColumnsCheck
2
2
  export * from 'rake-db';
3
3
  import { EnumColumn, DomainColumn, RawSQL, ArrayColumn, VirtualColumn, UnknownColumn, defaultSchemaConfig, columnsShapeToCode, Adapter } from 'pqb';
4
4
  import { deepCompare, toArray, addCode, codeToString, toCamelCase, toPascalCase, getImportPath, singleQuote, quoteObjectKey, pathToLog } from 'orchid-core';
5
- import fs from 'fs/promises';
6
5
  import path from 'node:path';
6
+ import fs from 'fs/promises';
7
7
  import typescript from 'typescript';
8
8
 
9
9
  const compareSqlExpressions = async (tableExpressions, adapter) => {
@@ -2238,7 +2238,7 @@ const invalidConfig = (config) => new Error(
2238
2238
  );
2239
2239
  const getDbFromConfig = async (config, dbPath) => {
2240
2240
  var _a, _b;
2241
- const module = await config.import(dbPath);
2241
+ const module = await config.import(path.resolve(config.basePath, dbPath));
2242
2242
  const db = module[(_a = config.dbExportedAs) != null ? _a : "db"];
2243
2243
  if (!(db == null ? void 0 : db.$queryBuilder)) {
2244
2244
  throw new Error(
@@ -2282,7 +2282,7 @@ const migrateAndPullStructures = async (options, config, afterPull) => {
2282
2282
  }
2283
2283
  return { dbStructure, adapters };
2284
2284
  };
2285
- const compareDbStructures = (a, b, i, path) => {
2285
+ const compareDbStructures = (a, b, i, path2) => {
2286
2286
  let err;
2287
2287
  if (typeof a !== typeof b) {
2288
2288
  err = true;
@@ -2298,7 +2298,7 @@ const compareDbStructures = (a, b, i, path) => {
2298
2298
  a[n],
2299
2299
  b[n],
2300
2300
  i,
2301
- path ? `${path}[${n}]` : String(n)
2301
+ path2 ? `${path2}[${n}]` : String(n)
2302
2302
  );
2303
2303
  }
2304
2304
  } else {
@@ -2307,13 +2307,13 @@ const compareDbStructures = (a, b, i, path) => {
2307
2307
  a[key],
2308
2308
  b[key],
2309
2309
  i,
2310
- path ? `${path}.${key}` : key
2310
+ path2 ? `${path2}.${key}` : key
2311
2311
  );
2312
2312
  }
2313
2313
  }
2314
2314
  }
2315
2315
  if (err) {
2316
- throw new Error(`${path} in the db 0 does not match db ${i}`);
2316
+ throw new Error(`${path2} in the db 0 does not match db ${i}`);
2317
2317
  }
2318
2318
  };
2319
2319
  const getActualItems = async (db, currentSchema, internal, columnTypes) => {
@@ -2745,7 +2745,8 @@ const pull = async (options, config) => {
2745
2745
  }
2746
2746
  const baseTablePath = config.baseTable.getFilePath();
2747
2747
  const baseTableExportedAs = config.baseTable.exportAs;
2748
- const adapter = new Adapter(options[0]);
2748
+ const adapters = options.map((opts) => new Adapter(opts));
2749
+ const [adapter] = adapters;
2749
2750
  const currentSchema = adapter.schema || "public";
2750
2751
  const ctx = makeStructureToAstCtx(config, currentSchema);
2751
2752
  const asts = await structureToAst(ctx, adapter);
@@ -2817,10 +2818,14 @@ const pull = async (options, config) => {
2817
2818
  );
2818
2819
  const version = await makeFileVersion({}, config);
2819
2820
  await generate(options, config, ["pull"], { adapter, version });
2820
- const silentAdapter = adapter;
2821
- silentAdapter.silentArrays = adapter.arrays;
2822
- await saveMigratedVersion(silentAdapter, version, "pull.ts", config);
2823
- await adapter.close();
2821
+ await Promise.all(
2822
+ adapters.map(async (adapter2) => {
2823
+ const silentAdapter = adapter2;
2824
+ silentAdapter.silentArrays = adapter2.arrays;
2825
+ await saveMigratedVersion(silentAdapter, version, "pull.ts", config);
2826
+ await adapter2.close();
2827
+ })
2828
+ );
2824
2829
  };
2825
2830
 
2826
2831
  rakeDbCommands.g = rakeDbCommands.generate = {