@stonyx/orm 0.3.2-alpha.123 → 0.3.2-alpha.124
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.
|
@@ -466,7 +466,12 @@ export default class PostgresDB {
|
|
|
466
466
|
while (this._queuedWrites.length > 0) {
|
|
467
467
|
const writes = this._takeNextWriteGroup();
|
|
468
468
|
writes.forEach(write => this._inFlightWrites.add(write));
|
|
469
|
-
|
|
469
|
+
try {
|
|
470
|
+
await this._executeWriteGroup(writes);
|
|
471
|
+
}
|
|
472
|
+
catch (error) {
|
|
473
|
+
writes.filter(write => this._inFlightWrites.has(write)).forEach(write => write.reject(error));
|
|
474
|
+
}
|
|
470
475
|
}
|
|
471
476
|
}
|
|
472
477
|
_takeNextWriteGroup() {
|
|
@@ -552,9 +557,9 @@ export default class PostgresDB {
|
|
|
552
557
|
async _insertCreates(schema, creates) {
|
|
553
558
|
if (creates.length === 1)
|
|
554
559
|
return this._insertCreatesOneByOne(schema, creates);
|
|
555
|
-
const { sql, values } = this.deps.buildInsertMany(schema.table, creates.map(({ row }) => row));
|
|
556
560
|
let result;
|
|
557
561
|
try {
|
|
562
|
+
const { sql, values } = this.deps.buildInsertMany(schema.table, creates.map(({ row }) => row));
|
|
558
563
|
result = await this.requirePool().query(sql, values);
|
|
559
564
|
}
|
|
560
565
|
catch {
|
package/package.json
CHANGED
|
@@ -604,7 +604,11 @@ export default class PostgresDB {
|
|
|
604
604
|
while (this._queuedWrites.length > 0) {
|
|
605
605
|
const writes = this._takeNextWriteGroup();
|
|
606
606
|
writes.forEach(write => this._inFlightWrites.add(write));
|
|
607
|
-
|
|
607
|
+
try {
|
|
608
|
+
await this._executeWriteGroup(writes);
|
|
609
|
+
} catch (error) {
|
|
610
|
+
writes.filter(write => this._inFlightWrites.has(write)).forEach(write => write.reject(error));
|
|
611
|
+
}
|
|
608
612
|
}
|
|
609
613
|
}
|
|
610
614
|
|
|
@@ -702,10 +706,10 @@ export default class PostgresDB {
|
|
|
702
706
|
private async _insertCreates(schema: ModelSchema, creates: PreparedCreate[]): Promise<void> {
|
|
703
707
|
if (creates.length === 1) return this._insertCreatesOneByOne(schema, creates);
|
|
704
708
|
|
|
705
|
-
const { sql, values } = this.deps.buildInsertMany(schema.table, creates.map(({ row }) => row));
|
|
706
709
|
let result: { rows: Record<string, unknown>[] };
|
|
707
710
|
|
|
708
711
|
try {
|
|
712
|
+
const { sql, values } = this.deps.buildInsertMany(schema.table, creates.map(({ row }) => row));
|
|
709
713
|
result = await this.requirePool().query(sql, values);
|
|
710
714
|
} catch {
|
|
711
715
|
return this._insertCreatesOneByOne(schema, creates);
|