-
Notifications
You must be signed in to change notification settings - Fork 48
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
Conversation
8418089
to
ff8d18a
Compare
src/services/search-builder.js
Outdated
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) { |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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!
ff8d18a
to
a32354d
Compare
## [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))
🎉 This PR is included in version 7.6.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
# [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
🎉 This PR is included in version 8.0.0-beta.3 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Pull Request checklist: