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

@vocab doesn't expand all unprefixed iris while transacting #338

Closed
dpetran opened this issue Jan 12, 2023 · 0 comments · Fixed by #437
Closed

@vocab doesn't expand all unprefixed iris while transacting #338

dpetran opened this issue Jan 12, 2023 · 0 comments · Fixed by #437
Assignees
Labels
bug Something isn't working as expected needs specification

Comments

@dpetran
Copy link
Contributor

dpetran commented Jan 12, 2023

(def conn @(fluree/connect {:method :memory
                              :defaults
                              {:context
                               {:id "@id"
                                :type "@type"
                                :xsd "http://www.w3.org/2001/XMLSchema#"
                                :schema "http://schema.org/"
                                :sh "http://www.w3.org/ns/shacl#"
                                :rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
                                :rdfs "http://www.w3.org/2000/01/rdf-schema#"
                                :wiki "https://www.wikidata.org/wiki/"
                                :skos "http://www.w3.org/2008/05/skos#"
                                :f "https://ns.flur.ee/ledger#"}
                               :did
                               {:id "did:fluree:Tf1sbdG5vZrMvdcfpVN9btp3nkYPKgWNu2H",
                                :public "020154853f38da17df4f1ad6e5cd1c424bf82066708ece89514b975c807aeccc60",
                                :private "ccd238808e29bda00a62cd27c592d1ef16efdf1f473854e6b276409f36435aed"}}}))

(def ledger @(fluree/create conn "dan" {:context {"@vocab" "fluree:dan/"}}))

(def db1 @(fluree/stage ledger {"@id" "heyo"
                                  "x" "foo"
                                  "y" "bar"}))

(def db1* @(fluree/commit! db1))

;; seems to expand heyo to "fluree:dan/heyo" for querying
  @(fluree/query db1* {:context {"@vocab" "fluree:dan/"}
                       :where [['?s "@id" "heyo"]]
                       :select {'?s [:*]}})
  []

  ;; but it didn't expand it while transacting
  @(fluree/query db1* {:where [['?s "@id" "heyo"]]
                       :select {'?s [:*]}})
  [{:id "heyo", "x" "foo", "y" "bar"}]

  ;; here's everything
  @(fluree/query db1* {:where [['?s '?p '?o]]
                       :select ['?s '?p '?o]})
  [["heyo" :id "heyo"]
   ["heyo" "x" "foo"]
   ["heyo" "y" "bar"]
   ["y" :id "y"]
   ["x" :id "x"]
   [:f/Context :id "https://ns.flur.ee/ledger#Context"]
   [:f/Context :rdf/type :rdfs/Class]
   [:f/context :id "https://ns.flur.ee/ledger#context"]
   [:rdfs/Class :id "http://www.w3.org/2000/01/rdf-schema#Class"]
   [:rdf/type :id "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"]
   ["fluree-default-context" :id "fluree-default-context"]
   ["fluree-default-context" :rdf/type :f/Context]
   ["fluree-default-context"
    :f/context
    "{\"schema\":\"http://schema.org/\",\"wiki\":\"https://www.wikidata.org/wiki/\",\"xsd\":\"http://www.w3.org/2001/XMLSchema#\",\"type\":\"@type\",\"rdfs\":\"http://www.w3.org/2000/01/rdf-schema#\",\"@vocab\":\"fluree:dan/\",\"id\":\"@id\",\"f\":\"https://ns.flur.ee/ledger#\",\"sh\":\"http://www.w3.org/ns/shacl#\",\"skos\":\"http://www.w3.org/2008/05/skos#\",\"rdf\":\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"}"]
   [:id :id "@id"]]

I would expect @vocab to expand everything that isn't explicitly defined in the context, per the spec.

Our json-ld library seems to do the right thing, so maybe we're just not expanding before staging?

(json-ld/expand {"@context" {"@vocab" "fluree:dan/"}
                   "@id" "heyo"
                   "x" "foo"
                   "y" "bar"})
  {:idx [], :id "heyo", "fluree:dan/x" {:value "foo", :type nil, :idx ["x"]}, "fluree:dan/y" {:value "bar", :type nil, :idx ["y"]}}
@dpetran dpetran added the bug Something isn't working as expected label Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as expected needs specification
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants