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

allow users to clear the default context for queries #422

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
instaparse/instaparse {:mvn/version "1.4.12"}
metosin/malli {:mvn/version "0.9.2"}
com.fluree/json-ld {:git/url "https://github.com/fluree/json-ld.git"
:sha "a909330e33196504ef8a5411aaa0409ab72aaa35"}
:sha "010ea42e857eb1845fc390767d649aa539768d6f"}

;; logging
org.clojure/tools.logging {:mvn/version "1.2.4"}
Expand Down
6 changes: 6 additions & 0 deletions src/fluree/db/api/query.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@

(let [{:keys [context history t commit-details] :as _parsed} (history/history-query-parser query-map)

;; if context is explicitly nil, preserve it, otherwise fall back to default
context (if (or (contains? query-map :context)
(contains? query-map "@context"))
context
{})

;; from and to are positive ints, need to convert to negative or fill in default values
{:keys [from to at]} t
[from-t to-t] (if at
Expand Down
7 changes: 6 additions & 1 deletion src/fluree/db/query/fql/parse.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
:context-str
:context)
db-ctx (get-in db [:schema ctx-key])
q-ctx (or (:context q) (get q "@context"))]
;; if context is explicitly set to nil, preserve it
q-ctx (if (or (contains? q :context)
(contains? q "@context"))
(or (:context q) (get q "@context"))
;; otherwise, fall back to db-ctx
{})]
(json-ld/parse-context db-ctx q-ctx)))

(defn parse-var-name
Expand Down