Skip to content
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(search): enable to search for a big integer in an ID field #695

Merged
merged 3 commits into from
Apr 22, 2021

Conversation

adriguy
Copy link
Contributor

@adriguy adriguy commented Apr 21, 2021

Pull Request checklist:

  • Write an explicit title for the Pull Request, following Conventional Commits specification
  • Create automatic tests
  • Test manually the implemented changes
  • Review my own code (indentation, syntax, style, simplicity, readability)
  • Wonder if you can improve the existing code

@forest-bot
Copy link
Member

@adriguy adriguy force-pushed the fix/enable-to-search-for-big-int-in-id-field branch from 8418089 to ff8d18a Compare April 21, 2021 17:18
@adriguy adriguy changed the base branch from master to fix/impossible-to-search-for-big-int-when-there-are-regular-int April 21, 2021 17:18
@adriguy adriguy requested a review from larcin April 22, 2021 08:08
Comment on lines 101 to 116
const searchAsNumber = Number(params.search);
let value;

if (!Number.isNaN(searchAsNumber)) {
if (Number.isInteger(searchAsNumber)
&& !Number.isSafeInteger(searchAsNumber)
&& primaryKeyType instanceof DataTypes.BIGINT) {
// Numbers higher than MAX_SAFE_INTEGER need to be handled as strings to circumvent
// precision problems only if the field type is a big int.
value = params.search;
} else {
value = searchAsNumber;
}
}

if (value !== undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't it code duplication with what you added on the other PR ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes there are some parts that a clearly similar... 🤔
Not sure if we should refactor here and to what point. Let's discuss it!

@larcin larcin assigned adriguy and unassigned larcin Apr 22, 2021
Base automatically changed from fix/impossible-to-search-for-big-int-when-there-are-regular-int to master April 22, 2021 13:11
@adriguy adriguy force-pushed the fix/enable-to-search-for-big-int-in-id-field branch from ff8d18a to a32354d Compare April 22, 2021 14:01
@adriguy adriguy changed the title fix(search): enable to search for a big int in an ID field fix(search): enable to search for a big integer in an ID field Apr 22, 2021
@adriguy adriguy merged commit 9f8132c into master Apr 22, 2021
@adriguy adriguy deleted the fix/enable-to-search-for-big-int-in-id-field branch April 22, 2021 15:32
forest-bot added a commit that referenced this pull request Apr 22, 2021
## [7.6.3](v7.6.2...v7.6.3) (2021-04-22)

### Bug Fixes

* **search:** enable to search for a big integer in an ID field ([#695](#695)) ([9f8132c](9f8132c))
@forest-bot
Copy link
Member

🎉 This PR is included in version 7.6.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

forest-bot added a commit that referenced this pull request May 26, 2021
# [8.0.0-beta.3](v8.0.0-beta.2...v8.0.0-beta.3) (2021-05-26)

### Bug Fixes

* **smart-actions-change-hook:** record is no longer altered and is sent correctly ([#728](#728)) ([2ac7af8](2ac7af8))
* distribution charts using groupby on a relationship throws 403 Forbidden ([#725](#725)) ([30e6744](30e6744))
* regression when fetching has-many and not selecting any fields on a hasone/belongsto relation ([#720](#720)) ([74ed623](74ed623))
* **schema:** do not remove primary key fields from the schema when tables have foreign keys that are primary keys ([8844fb5](8844fb5))
* **search:** enable to search for a big integer in an ID field ([#695](#695)) ([9f8132c](9f8132c))
* **search:** searching for a big int value should not break if there is a regular integer field ([#694](#694)) ([af076ad](af076ad))
* **security:** patch ssri dependency vulnerability ([#690](#690)) ([6b0770d](6b0770d))

### Features

* **browsing-context:** allow `Forest-Context-Url` header to give the current browser url of users ([#665](#665)) ([c46fd66](c46fd66))
* **filters:** add support for the \`model.field IN array\` filter condition ([#719](#719)) ([5f58457](5f58457))
* add support for belongsTo and hasOne filters on related data ([#715](#715)) ([2bc769e](2bc769e))
* support yarn 2 plug n play install mode ([#698](#698)) ([64b5734](64b5734))

### BREAKING CHANGES

* **browsing-context:** users willing to use this header needs either to clean the allowed headers or to add this specific header in the CORS configuration
@forest-bot
Copy link
Member

🎉 This PR is included in version 8.0.0-beta.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

3 participants