Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(range-bounds): observe inclusive range bounds#9364

Merged
sushantdhiman merged 3 commits intosequelize:masterfrom
mjy78:master
May 7, 2018
Merged

fix(range-bounds): observe inclusive range bounds#9364
sushantdhiman merged 3 commits intosequelize:masterfrom
mjy78:master

Conversation

@mjy78
Copy link
Contributor

@mjy78mjy78 commentedApr 27, 2018
edited
Loading

Pull Request check-list

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

  • Doesnpm run test ornpm 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 follow the commit message conventions explained inCONTRIBUTING.md?

Description of change

Ensure the 'inclusive' property on range bounds is not lost when querying.

Closes#8176,#8471

@codecov
Copy link

codecovbot commentedApr 27, 2018
edited
Loading

Codecov Report

Merging#9364 intomaster willnot change coverage.
The diff coverage is100%.

@mjy78mjy78force-pushed themaster branch 3 times, most recently from9f9ec8f toa6e10abCompareMay 2, 2018 08:42
lib/utils.js Outdated
obj = obj || {};
return _.cloneDeepWith(obj, elem => {
// Special handling for the inclusive array property (for range types)
if (Array.isArray(elem) && elem.hasOwnProperty('inclusive')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This will execute for each clone operation I would like to avoid this if possible, there is also one more issue#8471

As you are using this type in real world, what do you think about having range type store values like

[{value:10,inclusive:true},{value:10,inclusive:true}]

Rather than having non-standard array property?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I agree that not having to worry about special handling for the non-standard "inclusive" array property would be much cleaner. We should move to a standard representation of range types for both query predicates and query results ensuring the inclusive property is still maintained when results are converted to JSON.

This will be a breaking change though, as we (and I expect many others) have a lot of code that expects range values returned in query results to be of the form

[ 10, 10 ]

Another approach might be to allow range types to have a 3rd "options" element in the array. When querying/inserting you could define your range as any of

[ 10, 10 ] // Defaults to inclusive [true, false][ 10, 10, { inclusive: true }][ 10, 10, { inclusive: [ true, false ] }]

Query results would always be returned as

[ 10, 10, { inclusive: [ true, false ] }]

This will still be a breaking change, but may lessen the impact on those queries that currently use ranges in their default form (without being concerned about inclusivity).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

As we are under v5 beta process I would prefer just do one time switch to proper format, which will solve bothclone andstringify issues

[{value:10,inclusive:true},{value:10,inclusive:true}]

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

No problem. Is it ok if I make these changes under this pull request? There'll be some documentation changes too which I'll try to cover.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yeah no problem

Copy link
Contributor

@sushantdhimansushantdhiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Looks good, just a small documentation change

range // [{ value: Date, inclusive: false }, { value: Date, inclusive: true }]
```

Make sure you turn that into a serializable format before serialization since array
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

A note here saying that you will need to callreload after updating an instance with range type or usereturning: true option

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Done.

@sushantdhimansushantdhiman requested a review froma teamMay 7, 2018 07:00
BREAKING CHANGE: range values are now returned as an array    of two objects with each containing a property for the value and    a property for its bounds inclusion, rather than bounds inclusion    being defined as an array property. When inserting/querying,    bounds inclusion must also be defined in the same way.    This change ensures that bounds inclusivity is not lost when    serializing or logging data returned in query results.    To migrate code, follow the example below:    Before:    range: [10, 20];    range.inclusive = [false, true];    After:    range: [{ value: 10, inclusive: false }, { value: 20, inclusive: true }];Closessequelize#8176,sequelize#8471
@sushantdhimansushantdhiman requested a review froma teamMay 7, 2018 07:20
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

2 more reviewers

@janmeierjanmeierjanmeier approved these changes

@sushantdhimansushantdhimansushantdhiman approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@mjy78@janmeier@sushantdhiman

[8]ページ先頭

©2009-2026 Movatter.jp