Skip to content

feat(hasOne): sourceKey support + key validation - #9382

Merged
sushantdhiman merged 5 commits into
masterfrom
has-one-source-key
May 3, 2018
Merged

sushantdhiman merged 5 commits into
masterfrom
has-one-source-key

Conversation

@sushantdhiman

@sushantdhiman sushantdhiman commented May 2, 2018 •

Copy link
Copy Markdown
Contributor

Pull Request check-list

Please make sure to review and check all of these items:

  • Does npm run test or npm run test-DIALECT pass with this change (including linting)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Have you added new tests to prevent regressions?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Did you follow the commit message conventions explained in CONTRIBUTING.md?

Description of change

Closes #9229

@codecov

codecov Bot commented May 2, 2018 •

Copy link
Copy Markdown

Codecov Report

Merging #9382 into master will increase coverage by <.01%.
The diff coverage is 100%.

@sushantdhiman
sushantdhiman merged commit f365f72 into master May 3, 2018
@sushantdhiman
sushantdhiman deleted the has-one-source-key branch May 3, 2018 14:53
@callmez

callmez commented Jul 13, 2018 •

Copy link
Copy Markdown

hi, i m confuse that is this change support call with include method?
cause it's still not work for me.

const User = this.sequelize.define('User', {
    id: {
      type: DataTypes.INTEGER(11),
      allowNull: false,
      primaryKey: true,
      autoIncrement: true,
    },
    username: {
        type: Sequelize.STRING,
        unique: true,
       field: 'the_user_name_field'
    }
});
const Task = this.sequelize.define('Task', {
    title: Sequelize.STRING,
    username: Sequelize.STRING
});

User.hasOne(Task, { as: 'Task', foreignKey: 'username', sourceKey: 'username' });
User.findOne({ 
    where: { username: 'bob' },
    include: [ 'Task' ],
}); // for mysql still generate sql "ON `user`.`id` = `Task`.`username`"

@sushantdhiman

Copy link
Copy Markdown
Contributor Author

v5 only

@callmez

callmez commented Jul 13, 2018

Copy link
Copy Markdown

v5 still not work for me.

@sushantdhiman

Copy link
Copy Markdown
Contributor Author

report an issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants