Issues with the generated sql files
Hey there guys, I used the following docs (https://orm.drizzle.team/docs/rqb) about using
drizzle-query
to include tables but I am getting "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(sections_courses
.ind
, sections...' at line 1" error. Am I missing some options in my
schema.ts` file or other config thing? Thanks in advanceDrizzle ORM - Query
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
8 Replies
schema.ts
section.model.ts
not enough info on the error. paste the whole error & note the line down in console. it should point to the code that's erroring out. at least line number.
This the full error log
and what does it point to towards code? like it should point towards a line number in your editor. if it doesn't, then you need to use
console.log
or debugger to find where the error lies in the code. try commenting stuff out one-by-one where you think the code is unreachable.
if you know binary search, then you can do a half-way comment & see if it reaches that part of the code.
you need to put more effort mate to find it. the error is what it says it is. a syntax error somewhere in the code.
maybe see if the same code works if you use another database like sqlite. then you can come back & try to fix it.
or better yet, make a minimal reproduction on github/stackblitz with just the error. ik its a lot of work. will take 1-2 hours but you'll learn quickly that way & find the error faster.I already tried commenting some part of the code and found that the
with
section in the section.model.ts
causing it but the weird thing is I am getting sql error which is generated by drizzle-ormsee if the sql query works in drizzle studio's sql runner... you can even paste it in drizzle runner... both can be found on drizzle studio
I tried that in phpmyadmin sql playground itβs throwing the same error
I get similar error, im trying to query a m-m relation
schema.ts (pretty sure thats correct, pasted only relevant info)
Query
Error
mysql Ver 15.1 Distrib 10.4.32-MariaDB, for Win64 (AMD64), source revision c4143f909528e3fab0677a28631d10389354c491