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
No, the idea was to always use queries inline for readability.
That seems like a very bad excuse. When building a data access layer it is very common to share queries, especially CTEs. Adding something like #72 also doesn't remove the ability to use queries inline.
Reacted by Colton Berry, Chris Walker, Qluxzz, Alessio Bolognino (PIC) and Andrea
Another option for sharing a base query: in named-sql-tag fragments are frozen and there is no append. You compose by nesting one fragment in another (sql`${baseQuery} WHERE id = ${id}`), and the values get renumbered for the outer query, so a shared base query never grows between requests.
Activity
felixfbecker commentedon Jan 10, 2018
No, the idea was to always use queries inline for readability.
cassiozen commentedon Jan 10, 2018
Would you consider adding such a feature, under a different method name? (PR #72)
slavik-m commentedon Mar 18, 2018
@cassiozen +1
I need it!
migueloller commentedon Jul 29, 2018
That seems like a very bad excuse. When building a data access layer it is very common to share queries, especially CTEs. Adding something like #72 also doesn't remove the ability to use queries inline.
samholmes commentedon Apr 8, 2019
I suggest
.concat()as a method name.olsonpm commentedon Jun 30, 2026
Anyone looking for an immutable approach can check out my solution at sql-tagged-templates
It uses nesting to solve this problem e.g.
RagedPanda commentedon Nov 13, 2026
Another option for sharing a base query: in named-sql-tag fragments are frozen and there is no
append. You compose by nesting one fragment in another (sql`${baseQuery} WHERE id = ${id}`), and the values get renumbered for the outer query, so a shared base query never grows between requests.