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

Bug: dynamic table names are treated as parameterized queries #7

Open
mihar-22 opened this issue Jun 25, 2020 · 1 comment
Open

Bug: dynamic table names are treated as parameterized queries #7

mihar-22 opened this issue Jun 25, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@mihar-22
Copy link

mihar-22 commented Jun 25, 2020

Hey @terkelg!

Awesome library I'm loving it, thanks for making it. I'm trying to pass in table names dynamically but they are transformed into a parameterized query. Unfortunately SQL does not allow table names to be passed in this way. Is there a simple workaround or fix we could do for this case?

@mihar-22
Copy link
Author

I found a simple workaround:

sql

const tableName = 'myTable';

const myQuery = sql([`INSERT INTO ${tableName}`]);

// ...

query

const tableName = 'myTable';

const myQuery = query.from([tableName])

// ...

However, I still think this is a bug. Maybe the from clause can handle manually injecting in values and not parameterizing them.

@terkelg terkelg added the enhancement New feature or request label Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants