Json column type returning as plain string?

I have a schema for a json column (sqlite, proxy http driver) defined as: authors: text({ mode: 'json' }).notNull().$type<string[]>(),; and I'm able to save data into it by passing an array of strings: ['Mary Shelley']. However, when I run a select on that schema, I get back a string of the json: "[\"Mary Shelley\"]". Curious if that's expected, and/or if there is a way to automatically parse the resulting json. The type information for authors is showing up correctly as string[]. But the data is a plain string.
1 Reply
opaldraggy
opaldraggyOP•2mo ago
🤔 given I'm using the proxy http driver, and given that I don't see other issues filed with this same error, I'm guessing it's not a widespread bug. Instead; I'm guessing that data is getting double-escaped somewhere on the way in, and then escaped only once on the way out. Confirmed: the data stored in sqlite is "[\"Mary Shelley\"]"; and regular string column data is also saved as "foo" (instead of foo and [\"Mary Shelley\"]). The behavior seems eerily similar to https://github.com/drizzle-team/drizzle-orm/issues/724, but I'm not using posgres-js, but rather a sqlite text column and the proxy http driver. I'm on version 0.35.3. aand further debugging shows that drizzle is producing the correct params without doing any unnecessary escaping, so it's something I'm doing to the data after it comes out of drizzle and into my sqlite proxy. 🎉
Want results from more Discord servers?
Add your server