@deterministic-code/datasources 0.1.2 → 0.1.4
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.
|
@@ -145,6 +145,6 @@ export class ReadonlyRepository {
|
|
|
145
145
|
: "where" in query
|
|
146
146
|
? query
|
|
147
147
|
: this.readonlyStatements
|
|
148
|
-
? this.readonlyStatements.select(
|
|
148
|
+
? this.readonlyStatements.select(query)
|
|
149
149
|
: new SelectStatement({ where: query });
|
|
150
150
|
}
|
|
@@ -12,7 +12,7 @@ export class ReadonlyRepositoryBuilder {
|
|
|
12
12
|
const propertyMappings = options.propertyMappings ?? new IdentityMapper();
|
|
13
13
|
this.entityMapper = entityMapper;
|
|
14
14
|
this.propertyMapper = propertyMappings;
|
|
15
|
-
const entity =
|
|
15
|
+
const entity = options.entity ?? options.type?.name ?? "";
|
|
16
16
|
const names = options.readProperties ?? (options.type ? fieldNamesOf(options.type) : []);
|
|
17
17
|
if (objectConverter instanceof MetaDataRowTypeConverter && options.type) {
|
|
18
18
|
const instance = new options.type();
|
|
@@ -20,13 +20,15 @@ export class ReadonlyRepositoryBuilder {
|
|
|
20
20
|
objectConverter.referenceColumns = propertyMappings;
|
|
21
21
|
for (const name of names) {
|
|
22
22
|
const value = instance[name];
|
|
23
|
-
if (value !== null &&
|
|
23
|
+
if (value !== null &&
|
|
24
|
+
typeof value === "object" &&
|
|
25
|
+
!Array.isArray(value) &&
|
|
26
|
+
!(value instanceof Date) &&
|
|
27
|
+
!(value instanceof Uint8Array))
|
|
24
28
|
objectConverter.references.add(name);
|
|
25
29
|
}
|
|
26
30
|
}
|
|
27
|
-
const columns = [...names]
|
|
28
|
-
.map((name) => propertyMappings.map(name))
|
|
29
|
-
.sort((left, right) => left.localeCompare(right));
|
|
31
|
+
const columns = [...names].sort((left, right) => propertyMappings.map(left).localeCompare(propertyMappings.map(right)));
|
|
30
32
|
return {
|
|
31
33
|
connection,
|
|
32
34
|
rowConverter,
|
|
@@ -90,10 +90,11 @@ export class StoredProcedureBulkWriteStrategy {
|
|
|
90
90
|
const statements = repositoryParts(this.command.connection, this.options).statements;
|
|
91
91
|
const row = {};
|
|
92
92
|
for (const name of statements.readColumns) {
|
|
93
|
+
const physical = this.column(name);
|
|
93
94
|
if (create && this.identity(name) && !assigned(stored[name] ?? stored[this.ids()[0]]))
|
|
94
95
|
continue;
|
|
95
|
-
const match = Object.entries(stored).find(([key]) => this.column(key) ===
|
|
96
|
-
row[
|
|
96
|
+
const match = Object.entries(stored).find(([key]) => key === name || this.column(key) === physical);
|
|
97
|
+
row[physical] = match?.[1] ?? null;
|
|
97
98
|
}
|
|
98
99
|
return row;
|
|
99
100
|
};
|
|
@@ -35,7 +35,7 @@ export class MockConnection {
|
|
|
35
35
|
this.isOpen = false;
|
|
36
36
|
}
|
|
37
37
|
[Symbol.asyncDispose] = () => this.close();
|
|
38
|
-
async startTransaction(isolation = IsolationLevel.
|
|
38
|
+
async startTransaction(isolation = IsolationLevel.ReadCommitted) {
|
|
39
39
|
this.startTransactionCalls += 1;
|
|
40
40
|
if (this.startTransactionError) {
|
|
41
41
|
throw this.startTransactionError;
|