Fork me on GitHub
#portal
<
2021-10-15
>
esp119:10:05

Hi I've just started using Portal in VS Code (big thanks to @djblue for the tool and @seancorfield for helping me set it up!) - one strange thing I noticed when tap>-ing Datomic data into Portal is that :db/id values are not being shown correctly. My actual data has all distinct :db/id values, but when I inspect the data in Portal the :db/ids all show up as the same value. I'm wondering if :db/id has some special meaning in Portal that is conflicting with these values in Datomic data?

esp119:10:50

Here's an example. Note in the following tap the :db/ids are all different:

(tap> [{:db/id 4611681620380904123, :foo/id "FOO", :foo/children [#:db{:id 4611681620380904121} #:db{:id 4611681620380904122}]}])
But when it shows up in Portal all the :db/ids look like this:
▼ [
  ▼ {
    :db/id 4611681620380904000
    ▼ :foo/children [
      ▼ {
        :db/id 4611681620380904000
      }
      ▼ {
        :db/id 4611681620380904000
      }
    ]
    :foo/id "FOO"
  }
]

esp119:10:48

Oh now that I'm looking at it it looks like it's rounding all the :db/id values to 4611681620380904000

esp119:10:47

Yeah it looks like if I try sending any long value to Portal it will only keep 16 decimal places of precision:

(tap> 4611681620380904123)
shows up in Portal as:
4611681620380904000

seancorfield19:10:51

What data type are those :db/id values? I suspect this is cljs/JS interop...

seancorfield19:10:16

(so this is purely a display issue -- not that it helps you much)

esp119:10:21

JS represents all numbers as 64bit floating point, so it can't represent all longs precisely

esp119:10:24

It is just a display issue, but it would be nice if this could be addressed - when this first showed up I thought I screwed up my Datomic transaction data, when in reality it was fine

seancorfield19:10:28

Open an issue on the repo -- but I doubt much can be done given JS limitations.

djblue23:10:09

Dang, good catch! I'll see about fixing this soon :thumbsup:

👍 1
esp102:10:40

woo nice that was fast!

gotta_go_fast 1
esp102:10:48

could you publish a new version of the VS Code extension with this fix? or can i get a vsix file to use?

djblue02:10:34

Let me do some regression testing, but after that I can do a release 👌

esp102:10:08

sweet thank you thank you!

seancorfield02:10:01

@djblue Does that issue affect the browser version or just the VS Code version?

djblue02:10:38

All versions, so I'll be pushing out new versions of each 👌

seancorfield03:10:32

And of course we can't test it from a git deps because of the main.js thing, right?

djblue03:10:21

Yeah 😭 One day I'll get snapshot deploys working

esp108:10:35

awesome! thanks @djblue!

esp108:10:55

I tested too and it works great!

esp108:10:52

one thing I noticed tho is that longs show up as normal numbers in :portal.viewer/inspector and :portal.viewer/table, but in :portal.viewer/tree they show up like:

{
  :rep "4611681620380904123"
  :tag "long"
}

djblue15:10:41

Ooh, since I used a defrecord, the tree viewer is picking it up as a map 👌

esp118:11:55

sweet thank you!