Relational query erroring on workers + D1

Only able to get relation queries to work while running the worker in local mode. While running remote (--remote) or deployed it errors
[ERROR] Uncaught (in promise) Error: D1_ERROR

throw new Error("D1_ERROR", {
^
at _send
(../../../***/node_modules/wrangler/templates/d1-beta-facade.js:100:9)
[ERROR] Uncaught (in promise) Error: D1_ERROR

throw new Error("D1_ERROR", {
^
at _send
(../../../***/node_modules/wrangler/templates/d1-beta-facade.js:100:9)
To be clear .findMany() works remotely, but when adding a with it starts erroring
2 Replies
yeehow
yeehowOP2y ago
adding a .catch to the query shows this error. maybe this is more helpful?
Error: D1_ERROR
at D1Database._send (index.js:2886:13)
at async D1PreparedStatement.raw (index.js:2957:7)
at async PreparedQuery2.all (index.js:2367:18)
at async index.js:2761:18
at async Object.handle [as fetch] (index.js:21:30) {
stack: Error: D1_ERROR
at D1Database._send (index.js:…t async Object.handle [as fetch] (index.js:21:30),
message: D1_ERROR,
cause: Error: Error: too many arguments on function json_array
at D1Database._send (index.js:2887:16)

}
Error: D1_ERROR
at D1Database._send (index.js:2886:13)
at async D1PreparedStatement.raw (index.js:2957:7)
at async PreparedQuery2.all (index.js:2367:18)
at async index.js:2761:18
at async Object.handle [as fetch] (index.js:21:30) {
stack: Error: D1_ERROR
at D1Database._send (index.js:…t async Object.handle [as fetch] (index.js:21:30),
message: D1_ERROR,
cause: Error: Error: too many arguments on function json_array
at D1Database._send (index.js:2887:16)

}
Noticed that when including less columns the error goes away. Seems maybe the query is too long for D1? Is there a way to do .toSQL() with the new query syntax? Not too familiar with this stuff, but looks like SQLite has an argument limit for json_array https://sqlite.org/forum/info/5e7d54021a100e7297b9548723875881556d4c6644fc8b316564df32d1a0023f If I had to guess with D1 they have set a limit lower than standard sqlite. Which would explain why it runs fine locally, but doesn't remotely.
yeehow
yeehowOP2y ago
Yeah that is what it was. Current function argument max at 8. https://developers.cloudflare.com/d1/platform/limits/ On their discord they mentioned it would be bumped to 32 next week so that should solve my problems.
Limits · Cloudflare D1 docs
Many of these limits will increase during D1’s public alpha. Join the #d1-open-alpha channel in the Cloudflare Developer Discord to keep up to date …
Want results from more Discord servers?
Add your server