Skip to content

fix(query-generator): fix addColumn create comment - #10117

Merged
sushantdhiman merged 3 commits into
sequelize:masterfrom
mirkojotic:add-comment-on-add-column
Nov 5, 2018
Merged

sushantdhiman merged 3 commits into
sequelize:masterfrom
mirkojotic:add-comment-on-add-column

Conversation

@mirkojotic

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

Resolves #4386
More specifically #4386 (comment)
This adds on the work @theRichu started around adding an ability to add a comment while using addColumn API.

Initial PR can be found here
#10076

@mirkojotic mirkojotic changed the title Add comment on add column fix(query-generator): fix addColumn create comment Nov 3, 2018
@codecov

codecov Bot commented Nov 3, 2018 •

Copy link
Copy Markdown

Codecov Report

Merging #10117 into master will decrease coverage by 0.04%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
lib/dialects/mssql/query-generator.js 95.83% <100%> (+0.05%) ⬆️
lib/dialects/postgres/query-generator.js 94.08% <100%> (+0.06%) ⬆️
lib/utils.js 98.28% <0%> (-0.02%) ⬇️
lib/data-types.js 95.14% <0%> (-0.02%) ⬇️
lib/dialects/abstract/connection-manager.js 90% <0%> (ø) ⬆️
lib/hooks.js 97.05% <0%> (ø) ⬆️
lib/dialects/postgres/query.js 97.44% <0%> (ø) ⬆️
lib/dialects/postgres/range.js 100% <0%> (ø) ⬆️
lib/dialects/sqlite/data-types.js 97.15% <0%> (ø) ⬆️
lib/dialects/mssql/connection-manager.js 88.6% <0%> (ø) ⬆️
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3af0537...43790bd. Read the comment docs.

@sushantdhiman sushantdhiman left a comment

Copy link
Copy Markdown
Contributor

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

@sushantdhiman
sushantdhiman merged commit b896ba4 into sequelize:master Nov 5, 2018
@sushantdhiman

Copy link
Copy Markdown
Contributor

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}`;

Copy link
Copy Markdown

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.

Copy link
Copy Markdown
Contributor Author

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)) {

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

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.

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.

Comment property

5 participants