Repository navigation
Conversation
added 2 commits
April 1, 2018 18:43
Provides snake_case for all property names by setting field to snake_case
but keeping the name as camelCase.
The alternative is to manually define a hook.
sequelize.addHook('beforeDefine', (attributes) => {
Object.keys(attributes).forEach((name) => {
if (typeof attributes[name] !== 'function') {
attribute = attributes[name];
const _underscored = attribute.underscored === undefined ? sequelize.options.define.underscored : attribute.underscored;
console.log("NAME:", name, _underscored, attribute._underscored === undefined, sequelize.options.define.underscored, attribute.underscored);
if (attribute.field === undefined && _underscored !== undefined) {
attribute.field = sequelize.Utils.underscoredIf(name, _underscored);
}
}
});
});
Added define tests to validate correct output using underscored.
added 2 commits
April 2, 2018 13:04
Updated docs to make reference to new behaviour.
…elize#6423 - PR sequelize#9260 Provides consistent behaviour with new implementation for createdAt, updatedAt and deletedAt. Added checks to test. Removed unnecessary manipulation during init and just doing it in refreshAttributes
sushantdhiman
left a comment
Contributor
There was a problem hiding this comment.
See if you can cover full proposal from #6423 (comment)
Otherwise I will give it a shot when I get some time
Contributor
|
I have worked on this feature as foreignKey related work required some familiarity with current codebase. Thank you for this contribution. |
Contributor
Author
|
Thanks for working on the foreign key work. Hopefully it will go in the v5 release. |
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.
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
Can provide a fix for #6423 to match what most users expect when defining underscored in the options.
Provides snake_case for all property names by setting field to snake_case
but keeping the name as camelCase.
The alternative is to manually define a hook which most users won't.
NOTE: I run
npm run test-docker-unitsuccessfully.