Sequelize替换的双引号

时间:2018-05-31 11:30:34

标签: node.js postgresql escaping sequelize.js

我目前正在与Sequelize合作,在使用PostgreSQL替换构建原始查询时遇到问题。

**Expected**
sequelize.query('SELECT ? FROM users WHERE status = ?', {
    replacements: ['username', 'active'],
    type: sequelize.QueryTypes.SELECT
})

SELECT "username" FROM users WHERE status = "active"

**Actual**
sequelize.query('SELECT ? FROM users WHERE status = ?', {
    replacements: ['username', 'active'],
    type: sequelize.QueryTypes.SELECT
})

SELECT 'username' FROM users WHERE status = 'active'

查询无法运行,因为'无效,应该是"。有没有办法告诉Sequelize使用另一个角色来逃避数据?

我发现这个https://github.com/sequelize/sequelize/blob/master/lib/sql-string.js#L91似乎有'硬编码。

0 个答案:

没有答案