lovasoa / SQLpage

SQL-only webapp builder, empowering data analysts to build websites and applications quickly
https://sql.datapage.app
MIT License
1.29k stars 69 forks source link

parse error in `FOR JSON PATH` #127

Closed lovasoa closed 9 months ago

lovasoa commented 9 months ago

Discussed in https://github.com/lovasoa/SQLpage/discussions/126

Originally posted by **Pieter3033** November 8, 2023 Hi, The newest form component is really cool 🔥. I am currently struggling to populate the `options `of a `select type` in the `form` component. I am using MSSQL. I have attempted the following: `(SELECT Column1 AS label, Column2 AS value FROM MyTable FOR JSON PATH) AS options` Error: ![image](https://github.com/lovasoa/SQLpage/assets/141907966/ef20a898-cc6e-4b81-8597-2035032b9076) Note, I have tested this SQL statement inside of MSSQL and the output is as expected. Maybe I am struggling with the syntax? Regards
lovasoa commented 9 months ago

I reported the issue upstream to the sql parser library.

In the meantime, you have two options:

lovasoa commented 9 months ago

I wrote a fix for the parser, waiting for it to get merged: https://github.com/sqlparser-rs/sqlparser-rs/pull/1043

Pieter3033 commented 9 months ago

Hi @lovasoa, hope you are well.

Love the new update 🔥

I see that the sqlparser has been merged, has it been pushed in SQLPage 0.16.0 ?

lovasoa commented 9 months ago

Hi ! I'm fine, thank you :)

My pull request has been merged, but the new sqlparser still hasn't been released. I'll publish a SQLPage release after the sqlparser release, which @alamb should do beginning of next week.

Pieter3033 commented 9 months ago

Perfect.

Thank you for the feedback.

lovasoa commented 9 months ago

Good news for you ! Just merged the upstream change, we have FOR JSON in the latest development version of SQLPage.

You can try it now on docker with lovasoa/sqlpage:main, or wait for the big release which is coming in a few days max.

Pieter3033 commented 9 months ago

Perfect thank you for the update, looking forward to the next SQLPage update.

lovasoa commented 9 months ago

It's going to be a big one, with some long awaited features :)