bito-code-review[bot] commented on code in PR #44044:
URL: https://github.com/apache/superset/pull/44044#discussion_r4017628540
##########
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 update to use BigInt() for integer-string comparisons correctly
addresses the precision loss issue for values exceeding
Number.MAX_SAFE_INTEGER. Moving the check inside the string-string branch
ensures the logic is executed as intended, resolving the previous unreachable
branch issue.
**superset-frontend/packages/superset-ui-core/src/components/Select/utils.tsx**
```
if (
(typeof propertyA === 'bigint' ||
typeof propertyA === 'number' ||
(typeof propertyA === 'string' && /^-?\d+$/.test(propertyA))) &&
(typeof propertyB === 'bigint' ||
typeof propertyB === 'number' ||
(typeof propertyB === 'string' && /^-?\d+$/.test(propertyB)))
) {
const a = BigInt(propertyA);
const b = BigInt(propertyB);
```
--
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]