我目前正在与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似乎有'
硬编码。