-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
fix(query-generator): fix addColumn create comment #10117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(query-generator): fix addColumn create comment #10117
Conversation
Codecov Report
@@ Coverage Diff @@
## master #10117 +/- ##
==========================================
- Coverage 96.37% 96.33% -0.05%
==========================================
Files 63 63
Lines 9411 9431 +20
==========================================
+ Hits 9070 9085 +15
- Misses 341 346 +5
Continue to review full report at Codecov.
|
sushantdhiman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a small change
|
Thanks @mirkojotic |
| if (option && option.context === 'addColumn') { | ||
| const quotedAttr = this.quoteIdentifier(option.key); | ||
| const escapedCommentText = this.escape(attribute.comment); | ||
| sql += `; COMMENT ON COLUMN ${this.quoteTable(option.table)}.${quotedAttr} IS ${escapedCommentText}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this feature working?
I need to put some comments into a column to let know others devs of a team a small description of what's the purpose of the column.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@normancarcamo It was merged into master but you'll have to see which version of sequelize it will land in.
But also this is just the the addition to a PR merged a couple of months back that allowed this to be done on table creation. This PR is just so you could leverage this feature on addColumn API of query generator.
| dataType.field = key; | ||
| let commentStr = ''; | ||
|
|
||
| if (dataType.comment && _.isString(dataType.comment)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Post merge comment: Should use typeof
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SimonSchick Agreed. I was trying to be consistent with the rest of the codebase and lodash is already imported and used.
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
Resolves #4386
More specifically #4386 (comment)
This adds on the work @theRichu started around adding an ability to add a comment while using
addColumnAPI.Initial PR can be found here
#10076