Repository navigation
feat: forbid using attr names that are ambiguous with $nested.syntax$ - #13992
Merged
Merged
Conversation
Member
Author
|
I think we should forbid using here is a convoluted example of things breaking because an attribute name included a dot: const foo = sequelize.define('foo', {
'my.attribute': DataTypes.TEXT,
});
const my = sequelize.define('my', { attribute: DataTypes.TEXT });
foo.belongsTo(my);
await sequelize.sync({ force: true });
await foo.findAll({
include: [my],
where: {
'$my.attribute$': 'value' // will this reference foo['my.attribute'] or foo.my.attribute?
},
logging: console.log,
});
/*
SELECT "foo"."id",
"my.attribute",
"foo"."myId",
"my"."id" AS "my.id",
"my"."attribute" AS "my.attribute" // conflict here too!
FROM "foos" AS "foo"
LEFT OUTER JOIN "mies" AS "my"
ON "foo"."myId" = "my"."id"
WHERE "my"."attribute" = 'value';
*/Much safer to just ban doing this. Edit: I've included that change in this PR too. |
WikiRik
reviewed
Jan 30, 2022
| have been removed and all typings are now directly retrieved from the actual TypeScript code. | ||
| You'll likely find many tiny differences which however should be easy to fix. | ||
|
|
||
| ## Attributes cannot start and end with `$`, or include `.` |
Member
There was a problem hiding this comment.
Maybe good to add an example of how people can change the names of the attributes they are using?
8 tasks done
WikiRik
approved these changes
Feb 6, 2022
Member
|
Can we add this to the list of breaking changes in the migration docs? |
Member
Author
|
It is :) |
Member
|
Ah true :) Guess I didn't see it on my phone. Let's get this into main then! |
sdepold
pushed a commit
that referenced
this pull request
Feb 11, 2022
Contributor
|
🎉 This PR is included in version 7.0.0-alpha.9 🎉 The release is available on: Your semantic-release bot 📦🚀 |
4 of 6 tasks
vanthome
pushed a commit
to vanthome/sequelize
that referenced
this pull request
Jun 12, 2022
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Pull Request Checklist
npm run testornpm run test-DIALECTpass with this change (including linting)?Description Of Change
v7 only
It's currently possible to name an attribute
$name$or$na.me$. This is ambiguous with the$nested.syntax$that can be used in queries.This PR makes that syntax reserved and rejects any attribute named in a way that would be ambiguous with the nested attribute reference syntax.
It's opinionated as I found a couple places in the code where Sequelize tries to make it work, but there are many, many other places where it just silently breaks.
This is a breaking change, and should be marked as such when squashing the commits from this PR.