我使用sequelize在Redshift中进行查询。
但是Redshift对表列名不区分大小写,因此所有表名都是小写的。
sequelize模型不区分大小写。因此,当我执行查询findById时,它将执行以下查询:

SELECT "id", "userId", "summonerId", "name", "profileIconId", "summonerLevel", "revisionDate", "createdAt", "updatedAt" FROM "Lol" AS "Lol" WHERE "Lol"."id" = '463d118c-2139-4679-8cdb-d07249bd7777222';

如果我在Redshift中执行查询,它就可以工作,但是sequenceize只会把id和name列的名称带回来,因为在model中只有名称是小写的。
那我怎么才能让sequentize不区分大小写呢?我尝试了field选项,但没有成功。
所以我的模型是:
lol = sequelize.define('Lol', {
                id: {
                    type: Sequelize.STRING,
                    allowNull: false,
                    unique: true,
                    primaryKey: true,
                    field: 'id'
                },
                userId: {
                    type: Sequelize.STRING,
                    allowNull: false,
                    field: 'userid'
                },
                summonerId: {
                    type: Sequelize.INTEGER,
                    allowNull: false,
                    field: 'summonerid'
                },
                name: {
                    type: Sequelize.STRING,
                    allowNull: false,
                    field: 'name'
                },
                profileIconId: {
                    type: Sequelize.INTEGER,
                    allowNull: false,
                    field: 'profileiconid'
                },
                summonerLevel: {
                    type: Sequelize.INTEGER,
                    allowNull: false,
                    field: 'summonerlevel'
                },
                revisionDate: {
                    type: Sequelize.BIGINT,
                    allowNull: false,
                    field: 'revisiondate'
                },
                createdAt: {
                    type: Sequelize.DATE,
                    allowNull: false,
                    field: 'createdat'
                },
                updatedAt: {
                    type: Sequelize.DATE,
                    allowNull: false,
                    field: 'updatedat'
                }
            }, {
                freezeTableName: true,
                tableName: 'Lol'
            })

最佳答案

找到办法了。
下面是我的完整设置,使红移工作与续集:

var Sequelize = require('sequelize');
Sequelize.HSTORE.types.postgres.oids.push('dummy'); // avoid auto-detection and typarray/pg_type error
AWS.config.update({accessKeyId: 'accessKeyId', secretAccessKey: 'secretAccessKey', region: "xxxxxx"});
var sequelize = new Sequelize('database', 'username', 'password', {
    host: 'hostname',
    dialect: 'postgres',
    port: '5439',
    pool: {
        max: 10,
        min: 0,
        idle: 20000
    },
    returning: false, // cause sql error
    quoteIdentifiers: false, // set case-insensitive
    keepDefaultTimezone: true, // avoid SET TIMEZONE
    databaseVersion: '8.0.2' // avoid SHOW SERVER_VERSION

});

09-16 05:11
查看更多