Repository navigation
fix(model/init): add schema name to foreign key when generating sql s… - #9255
Merged
Merged
Conversation
sushantdhiman
left a comment
Contributor
There was a problem hiding this comment.
LGTM, but a few code improvements
| }); | ||
|
|
||
| it('supports schemas when defining custom foreign key attribute #9029', function() { | ||
| const self = this, |
Contributor
There was a problem hiding this comment.
No self, with arrow function we dont need special variable to access upper scope
| return self.sequelize.dropAllSchemas().then(() => { | ||
| return self.sequelize.createSchema('archive'); | ||
| }).then(() => { | ||
| return User.sync({force: true }); |
Contributor
There was a problem hiding this comment.
User.sync / Task.sync can be replaced with this.sequelize.sync
Contributor
Author
There was a problem hiding this comment.
schema is set using .schema() so .sync has to be called on each model separately according to this.
| }).schema('bar'); | ||
| BarProject.belongsTo(BarUser, { foreignKey: 'user_id' }); | ||
| it('references right schema when adding foreign key #9029', () => { | ||
| console.log(BarProject.rawAttributes); |
Contributor
There was a problem hiding this comment.
remove console.log :)
sushantdhiman
approved these changes
Apr 2, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…tatements (#9029) (#2464)
Pull Request check-list
Please make sure to review and check all of these items:
npm run testornpm run test-DIALECTpass with this change (including linting)?Description of change
Fixes #9029 and #2464. Using getTableName() so that schema is added to foreign key reference in generated sql statement.