@deterministic-code/datasources 0.1.3 → 0.1.5

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.
@@ -73,7 +73,9 @@ export class DefaultReadonlyEnrichmentStrategy {
73
73
  continue;
74
74
  map[String(entry)] = enrichment.relatedProperty
75
75
  ? (row[enrichment.relatedProperty] ?? null)
76
- : Object.fromEntries(Object.entries(row).filter(([name]) => name !== mapKey && name !== enrichment.relatedKey && name !== "Id" && name !== "id"));
76
+ : Object.fromEntries(Object.entries(row).filter(([name]) => name !== mapKey &&
77
+ name !== enrichment.relatedKey &&
78
+ !["id", "Id", "uuid", "Uuid", "created", "Created", "updated", "Updated", "version", "Version"].includes(name)));
77
79
  }
78
80
  Object.assign(parent, { [enrichment.destinationProperty]: map });
79
81
  }
@@ -145,6 +145,6 @@ export class ReadonlyRepository {
145
145
  : "where" in query
146
146
  ? query
147
147
  : this.readonlyStatements
148
- ? this.readonlyStatements.select(mappers.applyWhere(query, (name, cell) => this.cell(name, cell, false, options)))
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 = entityMapper.map(options.entity ?? options.type?.name ?? "");
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 && typeof value === "object" && !Array.isArray(value))
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) === name);
96
- row[name] = match?.[1] ?? null;
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
  };
@@ -1,7 +1,7 @@
1
1
  import { TypeConverter } from "./TypeConverter.js";
2
2
  import { IdentityMapper } from "../mappers/IdentityMapper.js";
3
3
  const scalarId = (value) => {
4
- if (value === undefined || value === null || typeof value !== "object" || value instanceof Date || value instanceof Uint8Array)
4
+ if (value === undefined || value === null || typeof value !== "object")
5
5
  return value === undefined ? undefined : value;
6
6
  const record = value;
7
7
  return record.Id !== undefined ? record.Id : record.id;
@@ -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.Serializable) {
38
+ async startTransaction(isolation = IsolationLevel.ReadCommitted) {
39
39
  this.startTransactionCalls += 1;
40
40
  if (this.startTransactionError) {
41
41
  throw this.startTransactionError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deterministic-code/datasources",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",