bito-code-review[bot] commented on code in PR #44044:
URL: https://github.com/apache/superset/pull/44044#discussion_r4017653003
##########
superset-frontend/packages/superset-ui-core/src/components/Select/utils.tsx:
##########
@@ -91,16 +91,21 @@ export const propertyComparator =
if (typeof propertyA === 'number' && typeof propertyB === 'number') {
return propertyA - propertyB;
}
- // BIGINT columns can decode to native `bigint` values (see json-bigint
- // parsing of large numeric values). Compare numerically rather than
- // falling through to the string fallback below, which would sort them
- // lexicographically (e.g. "10", "100", "2").
+ // BIGINT columns can decode to native `bigint` values or decimal strings
+ // (see parseResponse.ts). Compare numerically rather than falling through
+ // to the string fallback below, which would sort lexicographically.
if (
- (typeof propertyA === 'bigint' || typeof propertyA === 'number') &&
- (typeof propertyB === 'bigint' || typeof propertyB === 'number')
+ (typeof propertyA === 'bigint' ||
+ typeof propertyA === 'number' ||
+ (typeof propertyA === 'string' && /^-?\d+$/.test(propertyA))) &&
+ (typeof propertyB === 'bigint' ||
+ typeof propertyB === 'number' ||
+ (typeof propertyB === 'string' && /^-?\d+$/.test(propertyB)))
) {
- if (propertyA < propertyB) return -1;
- if (propertyA > propertyB) return 1;
+ const a = Number(propertyA);
+ const b = Number(propertyB);
Review Comment:
<!-- Bito Reply -->
The implementation described correctly addresses the precision loss issue
while avoiding the RangeError associated with passing float values to BigInt().
By separating the logic into distinct cases for strings, numbers, and bigints,
the code ensures that only valid integer-strings are converted to BigInt,
maintaining precision for large values while safely handling floating-point
numbers as standard numbers.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]