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

Pull doesn't work with entity ids like 5.036617769192117e+47 #33

Open
jpmonettas opened this issue Nov 3, 2018 · 3 comments
Open

Pull doesn't work with entity ids like 5.036617769192117e+47 #33

jpmonettas opened this issue Nov 3, 2018 · 3 comments

Comments

@jpmonettas
Copy link

jpmonettas commented Nov 3, 2018

Steps to reproduce:

(def c (d/create-conn))
(posh/posh! c)

(d/transact! c [[:db/add 1 :person/name "Rich"]
                       [:db/add 5.036617769192117e+47 :person/name "Alex"]])

@(posh/pull c '[:person/name] 1)
;; {:db/id 2, :person/name "Rich"}

@(posh/pull c '[:person/name] 5.036617769192117e+47)
;; nil


;; While it works in datascript
(d/pull @c '[:person/name] 5.036617769192117e+47)
{:person/name "Alex"}
@jpmonettas
Copy link
Author

Created a PR that fixes this issue (#34)

@metasoarous
Copy link
Collaborator

While it may be possible to use floating point ids in Datascript, I'm not sure its a good idea. There are likely performance implications, and I'd suspect you should be able to get around this by casting as an int.

@jpmonettas
Copy link
Author

I went for a reading and javascript stores everything as double precision floating point numbers, following the IEEE 754 standard. So everything is just 64 bit numbers where the number (the fraction) is stored in bits 0 to 51, the exponent in bits 52 to 62, and the sign in bit 63.

Looking at clojurescript code for "int casting" it just strip decimal places.

I think is a nice property to have posh pull interface to follow datascript pull one.

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