-
Notifications
You must be signed in to change notification settings - Fork 41
Add to Documentation/README that passing in string as Variable not Expression can convert string to SQL object #134
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
Comments
Sorry, the const SQL = require("sql-template-strings");
const exampleQuery = "SELECT * FROM example_table";
SQL([exampleQuery]);
//returns: SQLStatement { strings: ['SELECT * FROM example_table'], values: [] } |
I'm sorry if I overlooked it in the issue, but what was the exact problem with SQL`SELECT * FROM example_table`; ? |
My apologies for not being clear, there are no issues with the current command, I was suggesting an extension of functionality in the case where the developer may want to store certain query strings and variables and finds repeated calls to append inconvenient. For example const command = 'SELECT ';
const formatted_cols = ' to_char(date as 'yyyy-mm-dd') AS date'
const table = ' FROM example_table';
//more convenient:
SQL(command + formatted_cols + table);
//workaround:
SQL``.append(command).append(formatted_cols).append(table); |
I have the same problem and it's a great new funcionality. |
I love your package and have been using it extensively in my own project, but was having trouble converting some constants into SQL objects without using append. I figured out that calling SQL as a function and passing in a string variable does the trick. I would be happy to directly edit the README and submit a pull request if that works best.
Also I was wondering if it would be possible to create a new feature that allows the user to pass in an array of strings and get a complete SQL object in return, for example:
I would be happy to work on it and submit a pull request as well if that works best
The text was updated successfully, but these errors were encountered: