typescript-sql-tagged-template-plugin
typescript-sql-tagged-template-plugin copied to clipboard
How to use fragments inside sql queries?
Thank you for your wonderful extension!
As I understand fragments are supposed to be parts of sql queries, they are useless otherwise. But how to include them inside sql queries?
const photoJoin = sqlFragment`
INNER JOIN "photos" "photo" ON "photo"."authorId" = "user"."id"
`
const usersSql = sql`
SELECT * FROM "users" "user" ${photoJoin} WHERE userId=${userId}
`
But using this fragment leads to Failed to parse: syntax error at or near "$1".
error. Did I miss something? Thanks!