Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: array destructuring returning not iterable #39

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/modern-lizards-impress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'cf-bindings-proxy': patch
---

Return array responses instead of creating a new proxy for the response.
4 changes: 4 additions & 0 deletions src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ export const createBindingProxy = <T>(bindingId: string, notChainable = false):
return data;
}

if (Array.isArray(data)) {
return data;
}

return createResponseProxy(bindingId, target, data);
};
},
Expand Down
6 changes: 4 additions & 2 deletions tests/proxy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ suite('bindings', () => {

const statements = insertQuery.map((query) => d1.prepare(query).bind('hello-world'));

const result = await d1.batch(statements);
expect(result.map((r) => r.success)).toEqual([true, true]);
const [insert1, insert2] = await d1.batch(statements);

expect(insert1?.success).toEqual(true);
expect(insert2?.success).toEqual(true);
});

test('prepare -> bind -> all (select)', async () => {
Expand Down
Loading