Skip to content

feat(perf): use ->> for single paths and strings - #14099

Closed
JerrySievert wants to merge 1 commit into
sequelize:mainfrom
JerrySievert:main
Closed

JerrySievert wants to merge 1 commit into
sequelize:mainfrom
JerrySievert:main

Conversation

@JerrySievert

Copy link
Copy Markdown

Breaking change to switch to ->> instead of #>> in the case of a
single element array or string

Pull Request Checklist

Please make sure to review and check all of these items:

  • Have you added new tests to prevent regressions?
  • Does yarn test or yarn test-DIALECT pass with this change (including linting)?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Did you update the typescript typings accordingly (if applicable)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Did you follow the commit message conventions explained in CONTRIBUTING.md?

Description Of Change

Breaking change, closes #14066. When a single element or a string are passed, use the single element JSONB operator ->> instead of the pathing version #>>.

This is a change only for postgres.

Todos

Breaking change to switch to `->>` instead of `#>>` in the case of a
single element array or string
@WikiRik

WikiRik commented Feb 12, 2022

Copy link
Copy Markdown
Member

Thanks for the PR! It seems that two tests are still failing, can you take a look into that?

@JerrySievert

Copy link
Copy Markdown
Author

thanks for the reminder! I had paused after the end of work yesterday, and was planning on fixing the last of the tests this weekend.

@JerrySievert
JerrySievert marked this pull request as draft February 12, 2022 21:29
@JerrySievert

Copy link
Copy Markdown
Author

I converted to a draft until this is complete.

@fzn0x fzn0x added the performance For issues and PRs. Things that affect the performance of Sequelize. label Feb 16, 2022
@WikiRik WikiRik self-assigned this Mar 13, 2022
@WikiRik

WikiRik commented Sep 30, 2022

Copy link
Copy Markdown
Member

I've looked at this again, and after resolving the conflicts and updating tests there is only one test that requires more research/fixing;

it('should be able to query array using property accessor', async function () {
await Promise.all([
this.User.create({ username: 'swen', emergency_contact: ['kate', 'joe'] }),
this.User.create({ username: 'anna', emergency_contact: [{ name: 'joe' }] }),
]);
const user0 = await this.User.findOne({ where: Sequelize.json('emergency_contact.0', 'kate') });
expect(user0.username).to.equal('swen');
const user = await this.User.findOne({ where: Sequelize.json('emergency_contact[0].name', 'joe') });
expect(user.username).to.equal('anna');
});

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

Labels

performance For issues and PRs. Things that affect the performance of Sequelize.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow for ->> operator on single paths for JSONB (postgres)

3 participants