Skip to content

fix(createtable): pass table field name in attr - #11517

Closed
krazi3 wants to merge 2 commits into
sequelize:masterfrom
krazi3:bug-createtable
Closed

krazi3 wants to merge 2 commits into
sequelize:masterfrom
krazi3:bug-createtable

Conversation

@krazi3

@krazi3 krazi3 commented Oct 7, 2019

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 update the typescript typings accordingly (if applicable)?
  • Did you follow the commit message conventions explained in CONTRIBUTING.md?

Description of change

Closes #11285

Set tableName and fieldName on attribute with type ARRAY(ENUM)

@codecov

codecov Bot commented Oct 7, 2019

Copy link
Copy Markdown

Codecov Report

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

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #11517      +/-   ##
==========================================
+ Coverage   96.26%   96.26%   +<.01%     
==========================================
  Files          94       94              
  Lines        9181     9184       +3     
==========================================
+ Hits         8838     8841       +3     
  Misses        343      343
Impacted Files Coverage Δ
lib/dialects/postgres/data-types.js 96.26% <ø> (ø) ⬆️
lib/dialects/postgres/query-generator.js 94.4% <100%> (+0.04%) ⬆️

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 1fe2401...16a7926. Read the comment docs.

// Add table and field name if not exists on attributes with ARRAY(ENUM) type
if (!attribute.fieldName) {
attribute.fieldName = options.key;
attribute.tableName = options.table.tableName || options.table;

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.

attribute.tableName is not used anywhere else, I think.

@krazi3 krazi3 Oct 7, 2019

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.

Yes this looked a bit weird to me as well ... but i had to pass table info at line number 511, for the default value so that the enum name can be generated

if (this.type instanceof BaseTypes.ENUM) {
castKey = `${Utils.addTicks(
Utils.generateEnumName(options.field.Model.getTableName(), options.field.fieldName),
Utils.generateEnumName(options.field.tableName || options.field.Model.getTableName(), options.field.fieldName),

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.

Isn't options.table.tableName available here? It seems odd for attribute to keep tableName

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.

I don't think i get the table object in options ... i will check once again

@papb papb added status: awaiting response For issues and PRs. OP must respond (or change something, if it is a PR). Maintainers have no action type: bug DEPRECATED: replace with the "bug" issue type labels Oct 7, 2019
@sdepold

sdepold commented Oct 24, 2021

Copy link
Copy Markdown
Member

Hey there :)

First of all: Thanks a bunch for your contribution to Sequelize! Much appreciated!
Second: Unfortunately we haven't had the chance to look into this ever since you created it. Sorry for that!

A couple of months ago, we have switched from master to main branch as our primary development branch and hence this PR is now outdated :(

If you still think this change is making sense, please consider recreating the PR against main. Thanks in advance and sorry for the additional work.

✌️

@github-actions github-actions Bot removed the status: awaiting response For issues and PRs. OP must respond (or change something, if it is a PR). Maintainers have no action label Oct 24, 2021
@github-actions github-actions Bot added the stale label Nov 6, 2021
@WikiRik WikiRik removed the stale label Nov 15, 2021
@github-actions github-actions Bot added the stale label Nov 30, 2021
@fzn0x fzn0x removed the stale label Dec 31, 2021
@github-actions github-actions Bot added the stale label Jan 15, 2022
@WikiRik

WikiRik commented Jan 31, 2022

Copy link
Copy Markdown
Member

Closing this since it is still against master. Can be reopened if that changes.

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

Labels

stale type: bug DEPRECATED: replace with the "bug" issue type

Projects

None yet

Development

Successfully merging this pull request may close these issues.

queryInterface.createTable() does not work with ARRAY(ENUM) with defaultValue

6 participants