Skip to content

Commit 84c1583

Browse files
Allow leading zeros in tryParseInt (#2212)
1 parent 934712c commit 84c1583

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

packages/database/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Unreleased
2+
- [fixed] Fixed an issue that caused large numeric values with leading zeros to
3+
not always be sorted correctly.
4+
25
- [changed] Internal cleanup to Node.JS support.
36

47
# 6.4.0

packages/database/src/core/util/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ export const errorForServerCode = function(code: string, query: Query): Error {
546546
* @type {RegExp}
547547
* @private
548548
*/
549-
export const INTEGER_REGEXP_ = new RegExp('^-?\\d{1,10}$');
549+
export const INTEGER_REGEXP_ = new RegExp('^-?(0*)\\d{1,10}$');
550550

551551
/**
552552
* If the string contains a 32-bit integer, return it. Else return null.

packages/database/test/path.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ import { Path } from '../src/core/util/Path';
2020

2121
describe('Path Tests', function() {
2222
const expectGreater = function(left, right) {
23-
expect(Path.comparePaths(new Path(left), new Path(right))).to.equal(1);
24-
expect(Path.comparePaths(new Path(right), new Path(left))).to.equal(-1);
23+
expect(
24+
Path.comparePaths(new Path(left), new Path(right))
25+
).to.be.greaterThan(0);
26+
expect(Path.comparePaths(new Path(right), new Path(left))).to.be.lessThan(
27+
0
28+
);
2529
};
2630

2731
const expectEqual = function(left, right) {
@@ -117,5 +121,7 @@ describe('Path Tests', function() {
117121
expectGreater('/ab', '/a');
118122
expectGreater('/a/b', '/a');
119123
expectGreater('/a/b', '/a//');
124+
expectGreater('/a/0971500000', '/a/00403311635');
125+
expectGreater('/a/0971500000', '/a/971500000');
120126
});
121127
});

0 commit comments

Comments
 (0)