Error using "with" in nextjs

Hey, I'm using mysql and next.js and I'm migrating from Prisma to Drizzle. I don't know why, but when I try getting items using "with", it says: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(select coalesce(json_arrayagg(json_array(category_items.id, category_it...'at line 1. WIthout the "with" it works fine. My query: await db.query.category.findMany({ with: { items: true, }, }); and the relations: export const itemRelations = relations(item, ({ many, one }) => ({ incredients: many(itemingredient), addons: many(itemaddon), category: one(category, { fields: [item.categoryId], references: [category.id], }), sizes: many(size), orders: many(order), coupon: many(coupon), })); export const categoryRelations = relations(category, ({ many }) => ({ items: many(item), }));
9 Replies
Phil
Phil•9mo ago
similar to my issue: https://discord.com/channels/1043890932593987624/1227399755512942624 I hope its not a faulty version or something
K6rtsnik
K6rtsnikOP•9mo ago
I searched a little bit around the server and someone said that mariadb doesnt have the LATERAL keyword as mysql has So I think that's the problem
Phil
Phil•9mo ago
oh... yea that could be the problem... I wonder... if there is a mariaDB specific package
K6rtsnik
K6rtsnikOP•9mo ago
Searched for it also, but didnt find anything sadly
Phil
Phil•9mo ago
so it seams that mariaDB has their own package now. it is unfortunately not compatible with drizzle which makes sense, because its not the same commands, on the other hand im a bit anoied by mariadb for not having this SQL function...
K6rtsnik
K6rtsnikOP•9mo ago
yeah, same here 😛
Phil
Phil•9mo ago
and even more that the npm package they made isnt supported. but on the other hand it wouldnt make sence, because drizzle runns raw queries...i believe? so i guess we can only really switch to mysql, or postgres funnily enough it works even worse with mysql i got it to work on mysql, but in needed to change some things in my schema
Phil
Phil•9mo ago
there seems to be a PR, but the drizzle team didnt seem to prioritize it https://github.com/drizzle-team/drizzle-orm/pull/1692
GitHub
Add support for Maria DB (core API implementation) by L-Mario564 · ...
(Partially) Addresses #203. This PR aims to add support for Maria DB, which simply extends the existent MySQL dialect. Tasks: Implement mariadb driver. Write core API integration tests for the m...
K6rtsnik
K6rtsnikOP•9mo ago
Yeah, saw it also
Want results from more Discord servers?
Add your server