text mode json for sqlite Dq doesn't parse by default

I get SyntaxError: "undefined" is not valid JSON for json_string: text("json_string", { mode: "json" }) field. When I use methods like:
db.query.Issue.findMany();
db.query.Issue.findMany();
or
db.select().from(Issue)
db.select().from(Issue)
while it does work and return string, If I manually select it by:
db.select({
json_string: Issue.json_string
}).from(Issue)
db.select({
json_string: Issue.json_string
}).from(Issue)
I'm using D1 db.
1 Reply
Varna
VarnaOP9mo ago
support:dev: ⨯ SyntaxError: "undefined" is not valid JSON
support:dev: at JSON.parse (<anonymous>)
support:dev: at Proxy.mapFromDriverValue (/Users/varna/Code/Farmis/cloudflare/apps/support/.next/server/edge/chunks/ssr/01594_drizzle-orm_ee7e20._.js:1641:21)
support:dev: at mapRelationalRow (/Users/varna/Code/Farmis/cloudflare/apps/support/.next/server/edge/chunks/ssr/01594_drizzle-orm_ee7e20._.js:2312:75)
support:dev: at /Users/varna/Code/Farmis/cloudflare/apps/support/.next/server/edge/chunks/ssr/01594_drizzle-orm_ee7e20._.js:4524:392
support:dev: at Array.map (<anonymous>)
support:dev: at D1PreparedQuery.customResultMapper (/Users/varna/Code/Farmis/cloudflare/apps/support/.next/server/edge/chunks/ssr/01594_drizzle-orm_ee7e20._.js:4524:34)
support:dev: at D1PreparedQuery.mapAllResult (/Users/varna/Code/Farmis/cloudflare/apps/support/.next/server/edge/chunks/ssr/01594_drizzle-orm_ee7e20._.js:5188:25)
support:dev: at D1PreparedQuery.all (/Users/varna/Code/Farmis/cloudflare/apps/support/.next/server/edge/chunks/ssr/01594_drizzle-orm_ee7e20._.js:5178:21)
support:dev: at async Page (/Users/varna/Code/Farmis/cloudflare/apps/support/.next/server/edge/chunks/ssr/[root of the server]__68b133._.js:677:20)
support:dev: ⨯ SyntaxError: "undefined" is not valid JSON
support:dev: at JSON.parse (<anonymous>)
support:dev: at Proxy.mapFromDriverValue (/Users/varna/Code/Farmis/cloudflare/apps/support/.next/server/edge/chunks/ssr/01594_drizzle-orm_ee7e20._.js:1641:21)
support:dev: at mapRelationalRow (/Users/varna/Code/Farmis/cloudflare/apps/support/.next/server/edge/chunks/ssr/01594_drizzle-orm_ee7e20._.js:2312:75)
support:dev: at /Users/varna/Code/Farmis/cloudflare/apps/support/.next/server/edge/chunks/ssr/01594_drizzle-orm_ee7e20._.js:4524:392
support:dev: at Array.map (<anonymous>)
support:dev: at D1PreparedQuery.customResultMapper (/Users/varna/Code/Farmis/cloudflare/apps/support/.next/server/edge/chunks/ssr/01594_drizzle-orm_ee7e20._.js:4524:34)
support:dev: at D1PreparedQuery.mapAllResult (/Users/varna/Code/Farmis/cloudflare/apps/support/.next/server/edge/chunks/ssr/01594_drizzle-orm_ee7e20._.js:5188:25)
support:dev: at D1PreparedQuery.all (/Users/varna/Code/Farmis/cloudflare/apps/support/.next/server/edge/chunks/ssr/01594_drizzle-orm_ee7e20._.js:5178:21)
support:dev: at async Page (/Users/varna/Code/Farmis/cloudflare/apps/support/.next/server/edge/chunks/ssr/[root of the server]__68b133._.js:677:20)
I tried saving and removing data in both ways: JSON and JSON.stringify
Want results from more Discord servers?
Add your server