Config `option` are not being picked up and used.

オープン
#1,139 コメント 2 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
42/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
javascript, postgres
領域
cli, databases

調査の方向性

Start by reproducing the configuration shown in .sequelizerc and myconfig.js, using the model:generate command with the PostgreSQL dialect. Trace the CLI's config loading and option handling, then verify that define options affect generated migration columns: paranoid adds deleted_at and underscored maps createdAt and updatedAt to snake case.

索引モデルが issue の本文から書いたものです。

説明

What you are doing?

Sequelize has a parameter in it's constructor called options https://sequelize.org/api/v6/class/src/sequelize.js~sequelize#instance-constructor-constructor
which has an item called define (more on the define) where additional items such as underscored, paranoid, timestamps etc. can be specified.

In my custom config file specified in the .sequelizerc, I have the that options object, however, they are not being picked up.
It seems like only the underscored work if and only if included in the model:generate as an option --underscored

// .sequelizerc
module.exports = {
  'config': path.resolve('src', 'myconfig.js'),
  'models-path': path.resolve('src', 'models')
};
// myconfig.js

const username = process.env.DATABASE_USERNAME;
const password = process.env.DATABASE_PASSWORD;
const database = process.env.DATABASE_NAME;
const host = process.env.DATABASE_HOST;
const dialect = 'postgres';
const options = {
  define: {
    underscored: true,
    paranoid: true,
  },
};

module.exports = { username, password, database, host, dialect, options };

// Also tried this:
const define = {
  underscored: true,
  paranoid: true
};

module.exports = { username, password, database, host, dialect, define };

What do you expect to happen?

I expect the config attributes to be picked up and work such that the migration file would include a deleted_at and the createdAt and updatedAt would be created_at and updated_at respectively.

What is actually happening?

It's not picking them up and using the default behaviour. It works exactly the same way with and without the options.
The deleted_at is not created. The createdAt and updatedAt remain the same.

Dialect: postgres
Sequelize CLI version: 6.4.1
Sequelize version: 6.21.3

Edit 1:

include the module.exports in the myconfig.js as per the comment: https://github.com/sequelize/cli/issues/1139#issuecomment-1219506878

主要言語
JavaScript
スター
2.6k
フォーク
524
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

sequelize/cli のほかの issue

sequelize/cli の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。