Conditional logic within template strings not supported on raw MySQL query
I am trying to execute raw SQL query with some conditional logic but it always fails. It's working fine with
mysql2
driver.
Generated Query:
Params:
9 Replies
First question, are you using raw query on purpose or you just didn't find how to make this query in drizzle?
maybe I can help you to make it work with drizzle
That would be great. I didn't find a way to convert the above query into drizzle.
Could you also please tell me why the above fails as I will be doing a lot of raw queries in the future.
Really appreciate your quick reply. Thanks, man.
Don't look and logic, just a small example on how to combine filter and pass them to .where + how to setup count()
We didn't have all of that in docs yet, but it will be very soon
Ping me if everything worked or not
I don't know why it;s not formatting
worked
Will try it out and let you know.
Something this simple is also failing. I am using
deno
, so maybe something to do with mysql driver.
But, I haven't tested it with node
.yeah, you need to write
in this case it will work well
Yeah, it works, but fails with any conditional logic in it.
I was able to convert the above query to drizzle with your example.
Thank you for your help.
@a_sherman I wanted to ask if those functions from the
drizzle-orm
package can work outside of Node/Drizzle? I am a Deno user that is looking to try and experiement with Turso and was thinking if I may be able to add thisIt should work there. We didn't have a chance to try out Deno, but you can give it a shot
@Andrew Sherman ah I gave it ago and while I can import from
Esm.sh
looks like there's some node specific code that when imported breaks Deno. I think it's still something I'd like to dive into more this week so if I gain any traction will notify through an issue