Skip to content

Allow leading zeros in tryParseInt #2212

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

Merged
merged 4 commits into from
Sep 30, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/database/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Unreleased
- [fixed] Fixed an issue that caused large numeric values with leading zeros to
not always be sorted correctly.

- [changed] Internal cleanup to Node.JS support.

# 6.4.0
Expand Down
2 changes: 1 addition & 1 deletion packages/database/src/core/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ export const errorForServerCode = function(code: string, query: Query): Error {
* @type {RegExp}
* @private
*/
export const INTEGER_REGEXP_ = new RegExp('^-?\\d{1,10}$');
export const INTEGER_REGEXP_ = new RegExp('^-?(0*)\\d{1,10}$');

/**
* If the string contains a 32-bit integer, return it. Else return null.
Expand Down
5 changes: 3 additions & 2 deletions packages/database/test/path.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import { Path } from '../src/core/util/Path';

describe('Path Tests', function() {
const expectGreater = function(left, right) {
expect(Path.comparePaths(new Path(left), new Path(right))).to.equal(1);
expect(Path.comparePaths(new Path(right), new Path(left))).to.equal(-1);
expect(Path.comparePaths(new Path(left), new Path(right))).to.be.greaterThan(0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing semicolon?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, on GitHub it is missing. But I swear that I have this locally (via the Prettier commit that once again got stuck somewhere...)

expect(Path.comparePaths(new Path(right), new Path(left))).to.be.lessThan(0);
};

const expectEqual = function(left, right) {
Expand Down Expand Up @@ -117,5 +117,6 @@ describe('Path Tests', function() {
expectGreater('/ab', '/a');
expectGreater('/a/b', '/a');
expectGreater('/a/b', '/a//');
expectGreater('/a/0971500000', '/a/00403311635');
});
});