malformed array literal when trying to insert a 2d array of strings
I am getting this error when trying to insert a 2d array of string into a
.varchar().array().array()
or a .jsonb()
field. The error is: An internal error occurred.: malformed array literal: \"[[\"saddas\",\"dasdsad\",\"dadad\",\"sdasda\"],[\"123213\",\"1321312\",\"1231313\"],[\"111111111\"],[\"aaaaaaaaa\"]]\"
It seems to me that drizzle is converting this array of arrays into this invalid serialized string. When I use .jsonb column type, the above is the error, when I use the varchar().array().array() I get the same error but with curly braces instead of square brackets. Pulling my hair out to figure out why this is isn't working as expected and I'm out of options. Thank you in advance 🙂1 Reply
"drizzle-kit": "^0.28.1",
"drizzle-orm": "^0.36.3"
And... It's on a postgresql db using
import { drizzle } from "drizzle-orm/node-postgres";
Ended up (temporarily) solving this by manually creating the sql array and inserting that. I don't think this is a permanent solution because it opens up sql-injection risks. Hopefully it might help someone else with a temporary solution.