Skip to content

Raw query with named substitution parameters gets quoted parameters #4494

@czardoz

Description

@czardoz

I'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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueFor issues. An issue that is a good choice for first-time contributors.status: understoodFor issues. Applied when the issue is understood / reproducible.type: featureDEPRECATED: replace with the "feature" issue type

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions