You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Due to pagination I need to make queries with different sort orders and even different column, but currently the @vercel/postgres clean my query, deleting my dynamic order.
// Worksawaitsql`SELECT * FROM metagame_cards ORDER BY occurrences DESC LIMIT ${query.pageSize} OFFSET ${query.page*query.pageSize}`;// Doesn't workawaitsql`SELECT * FROM metagame_cards ORDER BY ${columnSort} DESC LIMIT ${query.pageSize} OFFSET ${query.page*query.pageSize}`;// Doesn't workawaitsql`SELECT * FROM metagame_cards ORDER BY ${columnSort}${sortOrder} LIMIT ${query.pageSize} OFFSET ${query.page*query.pageSize}`;
Is there a way to (at least in a dangerous way) do this?
The text was updated successfully, but these errors were encountered:
constorderbyColumn=identifiers('occurrences');constorderbyDirection=sortOrder==='DESC' ? fragment`DESC` : fragment`ASC`;awaitsql`SELECT * FROM metagame_cards ORDER BY ${orderByColumn}${orderByDirection} LIMIT ${query.pageSize} OFFSET ${query.page*query.pageSize}`;
However, we don't know if that's going to be merged yet -- there's a good bit of security auditing to do and probably some discussions around API!
For now, you can use sql.query directly. It means you'll have to do some manual string-concatenation, which isn't the best, but it's the best workaround until something better like the above is merged!
Due to pagination I need to make queries with different sort orders and even different column, but currently the @vercel/postgres clean my query, deleting my dynamic order.
Is there a way to (at least in a dangerous way) do this?
The text was updated successfully, but these errors were encountered: