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(types): fix QueryInterface#bulkInsert attribute arg type #13945
Conversation
An alternative to this might be to give `AbstractDataTypeConstructor` a constructor method, along the lines of: ```ts interface AbstractDataTypeConstructor { new (): AbstractDataType; key: string; warn(link: string, text: string): void; } ``` Then all the types would become constructable. Is that desirable?
Both DB2 CI tests are failing with
https://github.com/sequelize/sequelize/runs/4798649046?check_suite_focus=true#step:7:2122 unsure what that is :/ |
Don't worry about the DB2 tests, we'll merge anyway :) |
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.
It's looking good. All that's missing is a type-test in the types/test
folder (basically just use the method with the right parameters).
Also, is your issue with AbstractDataTypeConstructor
resolved if we change its definition from
interface AbstractDataTypeConstructor {
key: string;
warn(link: string, text: string): void;
}
to
interface AbstractDataTypeConstructor extends Function {
key: string;
warn(link: string, text: string): void;
}
instead of adding the constructor? Because that's a change I was planning on doing
@ephys Thanks for the quick review! I'll take a look at the I don't think that making Adding
|
to return AbstractDataType not AbstractDataTypeConstructor
Thank you for the tests!
You're right, let's continue with your solution
That means
Definitely looks like a mistake, would you mind adding it to your changes?
I'm fine with including a small change like this one
Yes! :) Hopefully we'll be done with this soon enough
No need, unless you've carefully crafted your commits & request to not squash, we squash and merge PRs :) |
types/test/data-types.ts
Outdated
|
||
// JSONB | ||
expectTypeOf(new JSONB()).toEqualTypeOf<DataTypes.AbstractDataType>(); | ||
expectTypeOf(JSONB()).toEqualTypeOf<DataTypes.AbstractDataType>(); |
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.
Can you make sure that there is an empty line at the end of this file?
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.
should extend AbstractDataType not AbstractDataTypeConstructor
for the types affected by new constructor signature on AbstractDataType
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.
Looks good to me :)
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.
Yes, just needs a better title and then we can merge. @ephys can you take care of that and add this to the v6 project?
Thank you @ChristopherChudzicki :) |
Co-authored-by: Rik Smale <13023439+WikiRik@users.noreply.github.com>
🎉 This PR is included in version 7.0.0-alpha.6 🎉 The release is available on: Your semantic-release bot 📦🚀 |
…ze#13945) Co-authored-by: Rik Smale <13023439+WikiRik@users.noreply.github.com>
Pull Request Checklist
Please make sure to review and check all of these items:
npm run test
ornpm run test-DIALECT
pass with this change (including linting)?Description Of Change
This is a very small PR to improve the typings to
bulkInsert
and theJSON
/JSONB
data types.Motivation: I have a typescript seeders file that is seeding some JSONB columns in a postgres database. The seed file uses
queryInterface.bulkInsert
to insert a bunch of rows read from a file. But sincequeryInterface
does not know the model column types, it does know to convert a few specific columns to JSONB. It was suggested in #8310 (comment) to passattributes
as a 4th arg tobulkInsert
. But the existing types forattributes
seems to be incorrect. (Additionally I discoverednew Sequelize.JSONB()
was throwing a "not constructable" type error.)PS: I'm pretty new to ORMs. Sequelize has been great so far. That's for it!