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): change attributes type to 'object | undefined' #13467
Closed
Closed
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9c4b25e
fix(types): change attributes type to 'object | undefined'
aryem 12e1b49
style: remove addition semi colon
aryem 60f64b1
fix(types): update type of attributes in 'BulkUpdate' & 'BulkInsert'
aryem d55a876
Merge branch 'main' into bug-13466
sdepold File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
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.
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.
This isn't right either actually.
I don't know if there's already a type for this or not. At the top of my head, it should be moreso like:
note: this is mostly psuedocode, I don't remember the exact typings for col, fn, and literals.
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.
@allawesome497 Thanks for the suggestions and you are right. It isn't correct either. I think
ModelAttributes
from Model.d.ts seems to be appropriate here. What do you say?.sequelize/types/lib/model.d.ts
Line 1358 in 23aa67e
I might be wrong here, But my suggestion are deduced from its usage in the following methods:
sequelize/lib/dialects/abstract/query-generator.js
Line 250 in 23aa67e
sequelize/lib/dialects/abstract/query-generator.js
Line 337 in 23aa67e
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.
Such as this?
In usage:
If so, then I think that would be the ideal solution.
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.
@allawesome497 Sorry, I don't understand why do we need
{ include?: Array<Attribute<ModelAttr>>, exclude:? Array<Attribute<ModelAttr>>, }
and in what scenarioAttribute
could beLiteral | ModelAttr | [Literal | Fn | Col
?.Based on the usage in
QueryInterface.BulkUpdate
&QueryInterface.BulkInsert
type of attributes should:ModelAttributes
interface is already defined in model.d.tssequelize/types/lib/model.d.ts
Line 1361 in 5e9c209
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.
So
{ include?: Array<Attribute<ModelAttr>>, exclude:? Array<Attribute<ModelAttr>>, }
is needed because you can specify those instead of an array. It's mentioned here, though it doesn't go into depth about it.col
: the name of a column. Might not be accepted in sequelize, not sure.fn
: A function that is to server as an attribute. Say,fn('COUNT', col('my_column'))
for example. This might need to have an aliasliteral
: Literal sql to be injected as an attribute. I believe this needs an alias specified, so it would only be valid in that tuple.${item} AS ${alias}
.I could be wrong on a few things here though, since this is all from memory. I'm confident on fn and literal being usable in attributes though, at least with an alias specified.
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.
Oh I've recently seen another type that I didn't realized existed -
SequelizeMethod
. This is going to be what we want, rather thanLiteral | Fn | Col
as those functions extend this.