Skip to content

fix(datatypes): don't stringify range bounds when infinite (fixes: #8… - #8210

Merged
sushantdhiman merged 1 commit into
sequelize:masterfrom
FluentDevelopment:infinite-range-bound-fix
Aug 29, 2017
Merged

sushantdhiman merged 1 commit into
sequelize:masterfrom
FluentDevelopment:infinite-range-bound-fix

Conversation

@yazshel

@yazshel yazshel commented Aug 27, 2017

Copy link
Copy Markdown
Contributor

…192)

Pull Request check-list

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

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

Description of change

Fix range bound processing logic in RANGE.prototype.stringify to pass through range bounds of null or -Infinity/Infinity unchanged (ie. dont' pass these values to the range subtype's stringify function). This allows RANGE.stringify to correctly identify these as infinite bounds and format the range SQL output correctly.
Fixes: #8192

@mention-bot

Copy link
Copy Markdown

@yazshel, thanks for your PR! By analyzing the history of the files in this pull request, we identified @mickhansen, @janmeier and @felixfbecker to be potential reviewers.

@codecov

codecov Bot commented Aug 27, 2017 •

Copy link
Copy Markdown

Codecov Report

Merging #8210 into master will increase coverage by <.01%.
The diff coverage is 100%.

Comment thread lib/dialects/postgres/data-types.js Outdated
}
const valuesStringified = values.map(value => {
if (this.options.subtype.stringify) {
if (value === null || value === -Infinity || value === Infinity) {

@sushantdhiman sushantdhiman Aug 28, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

use includes here

if ([null, -Infinity, Infinity].includes(value)) {

May be Node 4 doesnt support it, if it doesn't then https://lodash.com/docs/#includes

@sushantdhiman sushantdhiman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, just one change

@yazshel
yazshel force-pushed the infinite-range-bound-fix branch from 0079130 to 482e30a Compare August 28, 2017 22:54
@yazshel

yazshel commented Aug 28, 2017

Copy link
Copy Markdown
Contributor Author

I've used _.includes(). (According to node.green, Array.prototype.includes isn't supported by Node 4)

@yazshel

yazshel commented Aug 28, 2017 •

Copy link
Copy Markdown
Contributor Author

I'm not sure why that AppVeyor build failed with this push - the test log is indicating there may be a memory leak in the MSSQL connection logic at a couple of places. However, I don't see how this could have been introduced as this change is specific to the postgres dialect and I've only changed only changed the one line since the original commit (which passed all tests):

      if (value === null || value === -Infinity || value === Infinity) {

to

       if (_.includes([null, -Infinity, Infinity], value)) {

? Is there an intermittent issue with the MSSQL driver or another component here?

@sushantdhiman

Copy link
Copy Markdown
Contributor

Is there an intermittent issue with the MSSQL driver

Yes, I have restarted the build

@sushantdhiman
sushantdhiman merged commit 5d2ba05 into sequelize:master Aug 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Infinite range bounds are not handled correctly

4 participants