@takosjp/yurucommu-core 4.1.5 → 4.1.6
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/package.json
CHANGED
|
@@ -83,7 +83,7 @@ export interface EdgeSqlBinding {
|
|
|
83
83
|
/** All-or-none. 1..100 statements, ordered, one Host round trip. */
|
|
84
84
|
transaction(
|
|
85
85
|
statements: readonly EdgeSqlStatement[],
|
|
86
|
-
): Promise<readonly EdgeSqlResult[]>;
|
|
86
|
+
): Promise<{ readonly results: readonly EdgeSqlResult[] }>;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
export interface EdgeKvPutOptions {
|
|
@@ -158,6 +158,11 @@ export function createEdgeSqlDatabase(binding: EdgeSqlBinding) {
|
|
|
158
158
|
await one(prepare(sql, params), method);
|
|
159
159
|
|
|
160
160
|
const batchCallback: AsyncBatchRemoteCallback = async (batch) => {
|
|
161
|
+
if (batch.length < 1) {
|
|
162
|
+
throw new EdgeSqlShapeError(
|
|
163
|
+
"edge.sql: a transaction requires at least one statement",
|
|
164
|
+
);
|
|
165
|
+
}
|
|
161
166
|
if (batch.length > EDGE_SQL_MAX_STATEMENTS) {
|
|
162
167
|
throw new EdgeSqlShapeError(
|
|
163
168
|
`edge.sql: a batch of ${batch.length} statements exceeds the facade ` +
|
|
@@ -165,9 +170,26 @@ export function createEdgeSqlDatabase(binding: EdgeSqlBinding) {
|
|
|
165
170
|
);
|
|
166
171
|
}
|
|
167
172
|
const prepared = batch.map((entry) => prepare(entry.sql, entry.params));
|
|
168
|
-
const
|
|
173
|
+
const transaction = await binding.transaction(
|
|
169
174
|
prepared.map((entry) => ({ sql: entry.sql, params: entry.params })),
|
|
170
175
|
);
|
|
176
|
+
const keys =
|
|
177
|
+
typeof transaction === "object" &&
|
|
178
|
+
transaction !== null &&
|
|
179
|
+
!Array.isArray(transaction)
|
|
180
|
+
? Object.keys(transaction)
|
|
181
|
+
: [];
|
|
182
|
+
if (
|
|
183
|
+
keys.length !== 1 ||
|
|
184
|
+
keys[0] !== "results" ||
|
|
185
|
+
!Array.isArray(transaction?.results)
|
|
186
|
+
) {
|
|
187
|
+
throw new ProxyColumnMismatchError(
|
|
188
|
+
`edge.sql: transaction returned a malformed result envelope for ` +
|
|
189
|
+
`${prepared.length} statements`,
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
const { results } = transaction;
|
|
171
193
|
if (results.length !== prepared.length) {
|
|
172
194
|
throw new ProxyColumnMismatchError(
|
|
173
195
|
`edge.sql: transaction returned ${results.length} results for ` +
|