-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
postgres.js needs something like slonik's sql.join() for building dynamic queries #807
Comments
Yeah, I think it makes sense to add, but I've just been doing this when needed xs.flatMap((x, i) => i ? [sql`, `, x] : x) You can fairly quickly make a function to use instead if you feel like it - eg 😋 sql.join = (xs, joiner) => xs.flatMap((x, i) => i ? [joiner, x] : x) I'll keep the issue open for now. |
oh interesting! i would never have come up with that on my own do you have any reservations about adding this as a core feature? |
and if no reservations, would you accept a PR adding this as a core feature? |
It would be great to at least add the work-around to the docs. It wasn't obvious to me how to join sql fragments with a comma. Glad I found this. |
i'm working on a PR anyone want to bike-shed over |
postgres.js gives us parameterized tagged templates and the ability to nest sql partials, and this is fantastic, but I think it is missing a piece of the puzzle:
I
wantneed to be able concat partials together (that may contain query parameters), usually with some delimiter (eg whitespace, or a comma, or maybe an sql operator)slonik provides something like:
and I think it would be amazing if this were a first-class feature in postgres.js
this should allow things like
The text was updated successfully, but these errors were encountered: