Closed BigBlueHat closed 7 years ago
The original put
is quite aggressive which is why I've started contributing here and added a preserve
option, you might want to use it by default when you open the db. I'm not exactly sure about what happens with step 4 though. It's likely it will be addressed by using preserve: true
but it's still a bit mysterious.
Yeah. I'm adding it as an option to the playground per put()
.
However, it's currently false
in the playground. Which means I've also found this bit of mystery (which you can try in the console on the playground):
db.jsonld.put('{"@context": "https://schema.org/", "name": "BigBlueHat"}', console.log.bind(console));
Regardless of the above (which I assume are bugs), I think setting preserve
to true
by default is prudent. I'd much rather have messy data than no data. 😄
Yes I think having preserve to true by default makes sense too. @mcollina Should we go all the way here? (i.e. change the default to preserve true)
@BigBlueHat you might be interested in #46 as well
Ok I've been able to reproduce the problem @BigBlueHat and since I can build the playground now I'll work on a fix.
Well turns out there were several things at play here:
preserve
did need to be true
.base
shouldn't be put to _:
which basically means everything is a blank node (and blank node really aren't event supposed to be persisted, or let's say it's not trivial how they should be)So if you do correct the options and use a "@context" object then things work as expected. I'll get to the fix now.
New Playground with options settings is up!
Consequently, you'll find some more interesting things...
Basically, there's all kinds of crazy variations depending on where @base
shows up, what @id
is set to, or if any of its missing.
Right now, the playground is passing in {base: "", preserve: true}
by default, fwiw.
Oh, and db
and app
can be access from the console. app.displayTriples({})
is your friend there. 😄
I'm working on a test for this (and understanding more about what changed), but here's the set of steps for playing with on the playground.
expect(triples).to.have.length(1)
is trueexpect(triples).to.have.length(2)
is false...there's only one. It replaced (maybe?) the original statement that had the ID. 😕expect(triples).to.have.length(2)
is true...um...OK...expect(triples).to.have.length(3)
is true...gah! WAT?! I'm back down to 1 😢Obviously...I'm missing something important here... 😀
@jmatsushita thoughts?