Skip to content
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

Append sql without modifying the original sql #164

Open
guoqiao opened this issue Nov 11, 2021 · 1 comment
Open

Append sql without modifying the original sql #164

guoqiao opened this issue Nov 11, 2021 · 1 comment

Comments

@guoqiao
Copy link

guoqiao commented Nov 11, 2021

The append method will modify the original sql in place.
However, it's common that we need to define a common base sql (as const), and append different WHERE or ORDER BY conditons to it (to get a new SQL instance) for different situations, this is not available at the momment.

A suggested solution could be:
In additional to the append method, we can also define a + operator, to return a new sql, without changing original one.

@DenisFrezzato
Copy link

I had the same issue, so I've created a wrapper that also introaduces immutability: https://github.com/DenisFrezzato/sql-template-strings-ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants