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