Skip to content
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

BSON should convert Rat to Num where possible #23

Closed
lefth opened this issue Sep 27, 2017 · 1 comment
Closed

BSON should convert Rat to Num where possible #23

lefth opened this issue Sep 27, 2017 · 1 comment

Comments

@lefth
Copy link

lefth commented Sep 27, 2017

When floats/doubles are serialized to JSON then converted to Perl numbers, they're re-interpreted as Rat. Rat can't be handled by the database and gives an error.

Suggested solution: if Rat can be converted to Num without loss of data, do it. This will let BSON work with data that has been serialized without truncating data. (Verify that $n.Num.Rat == $n first.)

It would also be nice if BSON had an option that enabled truncating all floating point types to a type that is allowed in the database, even if some precision is lost. Perhaps $doc.accept-numbers, analogous to accept-hash which permits order information loss.

#23

lefth pushed a commit to lefth/BSON that referenced this issue Sep 27, 2017
See: MARTIMM#23
Note: Rakudo sometimes detects this incorrectly.
lefth pushed a commit to lefth/BSON that referenced this issue Sep 27, 2017
See: MARTIMM#23
Note: Rakudo sometimes detects this incorrectly.
lefth pushed a commit to lefth/BSON that referenced this issue Oct 20, 2017
See: MARTIMM#23
Note: Rakudo sometimes detects this incorrectly.
lefth pushed a commit to lefth/BSON that referenced this issue Oct 20, 2017
See: MARTIMM#23
Note: Rakudo sometimes detects this incorrectly.
lefth pushed a commit to lefth/BSON that referenced this issue Oct 20, 2017
See: MARTIMM#23
Note: Rakudo sometimes detects this incorrectly.
@MARTIMM
Copy link
Owner

MARTIMM commented Oct 22, 2017

PR is merged, thanks Dan

@MARTIMM MARTIMM closed this as completed Oct 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants