@entity-access/entity-access 1.0.338 → 1.0.340
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/common/Logger.d.ts +4 -0
- package/dist/common/Logger.d.ts.map +1 -1
- package/dist/common/Logger.js +22 -1
- package/dist/common/Logger.js.map +1 -1
- package/dist/migrations/Migrations.d.ts +8 -1
- package/dist/migrations/Migrations.d.ts.map +1 -1
- package/dist/migrations/Migrations.js +31 -1
- package/dist/migrations/Migrations.js.map +1 -1
- package/dist/migrations/postgres/PostgresAutomaticMigrations.d.ts +1 -0
- package/dist/migrations/postgres/PostgresAutomaticMigrations.d.ts.map +1 -1
- package/dist/migrations/postgres/PostgresAutomaticMigrations.js +7 -0
- package/dist/migrations/postgres/PostgresAutomaticMigrations.js.map +1 -1
- package/dist/migrations/sql-server/SqlServerAutomaticMigrations.d.ts +1 -0
- package/dist/migrations/sql-server/SqlServerAutomaticMigrations.d.ts.map +1 -1
- package/dist/migrations/sql-server/SqlServerAutomaticMigrations.js +9 -0
- package/dist/migrations/sql-server/SqlServerAutomaticMigrations.js.map +1 -1
- package/dist/model/EntityQuery.d.ts.map +1 -1
- package/dist/model/EntityQuery.js +5 -6
- package/dist/model/EntityQuery.js.map +1 -1
- package/dist/model/EntitySource.js +1 -1
- package/dist/tests/db-tests/tests/version-history.d.ts +3 -0
- package/dist/tests/db-tests/tests/version-history.d.ts.map +1 -0
- package/dist/tests/db-tests/tests/version-history.js +16 -0
- package/dist/tests/db-tests/tests/version-history.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/common/Logger.ts +26 -1
- package/src/migrations/Migrations.ts +46 -1
- package/src/migrations/postgres/PostgresAutomaticMigrations.ts +8 -0
- package/src/migrations/sql-server/SqlServerAutomaticMigrations.ts +10 -0
- package/src/model/EntityQuery.ts +5 -6
- package/src/model/EntitySource.ts +1 -1
- package/src/tests/db-tests/tests/version-history.ts +24 -0
package/src/model/EntityQuery.ts
CHANGED
|
@@ -222,10 +222,9 @@ export default class EntityQuery<T = any>
|
|
|
222
222
|
const updateStatement = this.getUpdateStatement(p, f, true);
|
|
223
223
|
|
|
224
224
|
await using scope = new AsyncDisposableScope();
|
|
225
|
-
const session = this.context.logger
|
|
225
|
+
const session = this.context.logger ?? Logger.nullLogger;
|
|
226
226
|
let query: { text: string, values: any[]};
|
|
227
227
|
try {
|
|
228
|
-
scope.register(session);
|
|
229
228
|
const type = this.type;
|
|
230
229
|
const signal = this.signal;
|
|
231
230
|
|
|
@@ -256,7 +255,7 @@ export default class EntityQuery<T = any>
|
|
|
256
255
|
|
|
257
256
|
const updateStatement = this.getUpdateStatement(p, f);
|
|
258
257
|
|
|
259
|
-
const session = this.context.logger
|
|
258
|
+
const session = this.context.logger ?? Logger.nullLogger;
|
|
260
259
|
let query;
|
|
261
260
|
try {
|
|
262
261
|
query = this.context.driver.compiler.compileExpression(this, updateStatement);
|
|
@@ -540,7 +539,7 @@ export default class EntityQuery<T = any>
|
|
|
540
539
|
const nq = new EntityQuery({ ... this, selectStatement: select });
|
|
541
540
|
|
|
542
541
|
await using scope = new AsyncDisposableScope();
|
|
543
|
-
const session = this.context.logger
|
|
542
|
+
const session = this.context.logger ?? Logger.nullLogger;
|
|
544
543
|
let query;
|
|
545
544
|
try {
|
|
546
545
|
query = this.context.driver.compiler.compileExpression(nq, select);
|
|
@@ -579,7 +578,7 @@ export default class EntityQuery<T = any>
|
|
|
579
578
|
const nq = new EntityQuery({ ... this, selectStatement: select });
|
|
580
579
|
|
|
581
580
|
await using scope = new AsyncDisposableScope();
|
|
582
|
-
const session = this.context.logger
|
|
581
|
+
const session = this.context.logger ?? Logger.nullLogger;
|
|
583
582
|
let query;
|
|
584
583
|
try {
|
|
585
584
|
query = this.context.driver.compiler.compileExpression(nq, select);
|
|
@@ -621,7 +620,7 @@ export default class EntityQuery<T = any>
|
|
|
621
620
|
const nq = new EntityQuery({ ... this, selectStatement: select });
|
|
622
621
|
|
|
623
622
|
await using scope = new AsyncDisposableScope();
|
|
624
|
-
const session = this.context.logger
|
|
623
|
+
const session = this.context.logger ?? Logger.nullLogger;
|
|
625
624
|
let query;
|
|
626
625
|
try {
|
|
627
626
|
query = this.context.driver.compiler.compileExpression(nq, select);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import assert from "assert";
|
|
2
|
+
import { BaseDriver } from "../../../drivers/base/BaseDriver.js";
|
|
3
|
+
import { ShoppingContext } from "../../model/ShoppingContext.js";
|
|
4
|
+
import { TestConfig } from "../../TestConfig.js";
|
|
5
|
+
|
|
6
|
+
export default async function (this: TestConfig) {
|
|
7
|
+
|
|
8
|
+
assert.equal(true, await migrate.call(this));
|
|
9
|
+
|
|
10
|
+
assert.equal(false, await migrate.call(this));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async function migrate(this: TestConfig) {
|
|
14
|
+
const { driver } = this;
|
|
15
|
+
|
|
16
|
+
const copy = { ...driver } as BaseDriver;
|
|
17
|
+
(copy as any).connectionString = { ...driver.connectionString };
|
|
18
|
+
Object.setPrototypeOf(copy, Object.getPrototypeOf(driver));
|
|
19
|
+
const context = new ShoppingContext(copy);
|
|
20
|
+
|
|
21
|
+
await context.connection.ensureDatabase();
|
|
22
|
+
|
|
23
|
+
return await context.connection.automaticMigrations().migrate(context, { version: "v1" });
|
|
24
|
+
}
|