Maximum call stack size exceeded: orderSelectedFields
I'm migrating from Prisma, and trying to replace an aggregate query. I'm getting an error with the following query, which is—as far as I can tell—right from the documentation on aggregate queries: https://orm.drizzle.team/docs/crud#aggregations
The error looks like an infinite loop—
Using the most recent version of Drizzle (0.28.6) and the Planetscale adapter.
Any thoughts on what's going on?
6 Replies
Figured the issue out, and it was strange. I have a monorepo with multiple projects, and I was exporting Drizzle helpers from my
packages/db
repo like so:
export * from "drizzle-orm";
I guess that was breaking the sql
helper class somehow. Changing the export to this—
And then calling drizzle.sql'...'
seems to have fixed it.How were you importing it where you were using it? This is interesting
import { sql, eq, inArray, ... } from "@project/db"
Which now reads
import { drizzle } from "@project/db"
The only explanation I can come up with is that you're importing
sql
twice
Drizzle support cjs and mjs and have both mjs and cjs exports
Maybe the import *
was bringing in bothOh interesting, maybe so! When I was debugging I tried running
sql"blahblah".getSQL()
and got an error that getSQL
didn't exist on the tagged template function. Would that happen if I was using cjs in an mjs environment or vice versa? (not sure which I'm in)I just got this today
for a simple insert