Raw query with named substitution parameters gets quoted parameters
See original GitHub issueI’m using sequelize to perform a simple raw query:
var queryStr = 'SELECT * FROM :tableName WHERE :deletionColumn > 0 LIMIT :limit;';
return self.connection.query(queryStr, {
replacements: {
tableName: self.name,
deletionColumn: self.options.deletionColumn,
limit: self.options.limit
}
}).then(function (rowsToDelete) {
_.each(rowsToDelete, function (row) {
log.debug('Preparing to delete row: ', row);
});
});
The resulting query however, is (from the sequelize logs):
Executing (default): SELECT * FROM 'test' WHERE 'deleted' > 0 LIMIT 421;
The generated query is invalid (table name must not be quoted).
Are there any options I can pass that’ll disable the quoting? I’m using MySQL 5.6 here.
Issue Analytics
- State:
- Created 8 years ago
- Comments:33 (12 by maintainers)
Top Results From Across the Web
How to avoid single quotes in sequelize query with ...
As a workaround I created the query and the sort order by separately and then concatenate them as follow: const query= `SELECT *...
Read more >Raw Queries - Sequelize
Replacements in a query can be done in two different ways, either using named parameters (starting with : ), or unnamed, represented by...
Read more >Passing parameters to SQL queries - Psycopg
Passing parameters to a SQL statement happens in functions such as Cursor.execute() by using %s placeholders in the SQL statement, and passing a...
Read more >Running parameterized queries | BigQuery - Google Cloud
To use a timestamp in a query parameter, the underlying REST API takes a value of type TIMESTAMP in the format YYYY-MM-DD HH:MM:SS.DDDDDD...
Read more >Raw queries - Manual | Sequelize
Replacements in a query can be done in two different ways, either using named parameters (starting with : ), or unnamed, represented by...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Almost 7 years and still nothing … Any update on this apart from the cricket in the background?
Yeah… this is a super old thread, but NOT having this actually eliminates me from being able to use this node module. This is a feature available in basically every other module out there and they mostly all use the same syntax too.
? - params ?? - table / column names
Sure, I could hack around in my code to fix this, but why should I when I can use another node module that won’t force me too? This is a missing feature!
Are you open to allowing a PR for this?