DataTables / DataTables/SearchBuilder
incorrect parsing of decimal numbers if decimal != "."
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 23
- Forks
- 20
- PR merge metrics
- No merged PRs in 30d
Description
I have a column that contains decimal numbers like: 33,3
Using language.decimal = ","
The column type is fixed using:
columnDefs = [{ type: 'num-fmt', searchBuilderType: 'num-fmt', targets: '_all' }]
When I build a search for values > 300, the row with value 33,3 shows up in the results.
Debugging the issue I found that 33,3 is interpreted as 333 in the comparison
The issue seems to be that the number is converted here to "33.3" already.
https://github.com/DataTables/SearchBuilder/blob/ae192b3a73e083969c7463e28f5904dc8930608f/src/criteria.ts#L1958
Later the "." is removed here, because "," is supposed to be the decimal symbol
https://github.com/DataTables/SearchBuilder/blob/ae192b3a73e083969c7463e28f5904dc8930608f/src/criteria.ts#L2121-L2130
I tested it using the latest versions Datatables v2.3.7 and SearchBuilder v1.8.4
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/criteria.ts at the conversion around line 1958 and the decimal-symbol handling around lines 2121-2130. Reproduce the issue with language.decimal set to "," and a num-fmt column, then verify that a value such as 33,3 is not returned by a search for values greater than 300.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100