Dynamic queries don't work
Maybe I'm some kind of special, but dynamic queries don't work for me ;(
Example from the documentation:
/* @name GetAllUsers */
SELECT * FROM users
ORDER BY (CASE WHEN :asc = true THEN :sort_column END) ASC, :sort_column DESC;
When I try to make queries everything runs without error, but sorting doesn't work
const users = await getAllUsers.run(
{
asc: false,
sort_column: 'id'
},
client
)
If you substitute id instead of :sort_column in the original query, then everything works
I experiencing the same issue, is this being looked into?
Same issue for me too.
It's unclear why this is even in the documentation. Looking at the tests it does not look like there are any to cover order by.
Also, it does not look like Postgres even supports this:
https://github.com/brianc/node-postgres/issues/300
You would have to do it using a shit load of case statements like so:
https://stackoverflow.com/a/48855828/4195244