Using jsonArrayFrom with mariadb.
Hello,
Madiadb does not have cast to JSON, and cannot reference nested subqueries.
I'm a typescript newbie. 🙂
How can I rewrite this function to achieve a similar result with Mariadb?
11 Replies
Without the JSON datatype, and more importantly, the JSON aggregate functions, it might be really difficult or impossible to implement similar functionality.
I'm not familiar enough with MariaDB to be able to help here
@lemnisk8 is there some reddit/discord you could ask in? show them the compiled SQL string Kysely produces for MySQL, and ask how to achieve this with MariaDB's SQL spec. If you find out, please share the SQL here and we could move forward with typescriptying it 🙂
Thanks @koskimas @Igal !!!
Mariadb now has support for json_arrayagg (since v10.5.0)
I am trying to recreate this SQL using jsonArrayFrom
This is my attempt to typescripting this.
https://kyse.link/?p=s&i=Y46rOpewvBx9hrsblIEz
Can you please check and suggest if this is the right approach and/or any corrections/pointer to doing this in a better way?
Well, the types are completely wrong in your code.
There are also errors as you can see in the playground
I got it to work but I don't know how 🙂 Can you please help me fix it...? I'm still trying to figure it out.
This should work https://kyse.link/?p=s&i=E2pHGv3tjF7YbfOf5vyJ
Thanks @koskimas!
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
Debug it. See what's in the actual node and compare it to the
if
checks. We can't do the work for you since we don't have your code
On quick glance it seems that the code expects each column reference to have a table. So this could work
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
You're welcome 😱 👌 🙃 ⭐ ✅ ❤️ 🤓 🥽 🐽 🍗 🔮