2017-02-08 16 views
1

Redshiftでsequelizeを使用してクエリを作成しています。モデルの大文字と小文字を区別しないでください

ただし、Redshiftはテーブルの列名では大文字と小文字を区別しないため、すべてのテーブル名は小文字になります。 モデルの後継は大文字と小文字を区別しません。だから私は、クエリfindByIdを行うとき、それはこのクエリを実行します。

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

私は赤方偏移の内側のクエリを実行した場合それは動作しますが、だけで名前の小文字を持っているので、sequelizeだけで、idとnameカラム名を私を持ち帰りますモデル。

どのようにして大文字と小文字を区別することができますか?私は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' 
      }) 

答えて

2

は方法を見つけました。ここで

今Sequelizeと赤方偏移の仕事を作るために私の完全な設定です:

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 

}); 
関連する問題