* escape queries correctly when querying realm * kill dead code
This commit is contained in:
parent
2c90faab86
commit
30ef161afa
|
@ -4,7 +4,8 @@
|
||||||
[status-im.data-store.realm.schemas.base.core :as base]
|
[status-im.data-store.realm.schemas.base.core :as base]
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[status-im.utils.fs :as fs]
|
[status-im.utils.fs :as fs]
|
||||||
[clojure.string :as str])
|
[clojure.string :as str]
|
||||||
|
[goog.string :as gstr])
|
||||||
(:refer-clojure :exclude [exists?]))
|
(:refer-clojure :exclude [exists?]))
|
||||||
|
|
||||||
(def realm-class (js/require "realm"))
|
(def realm-class (js/require "realm"))
|
||||||
|
@ -196,11 +197,6 @@
|
||||||
(js->clj res :keywordize-keys true))
|
(js->clj res :keywordize-keys true))
|
||||||
res)))
|
res)))
|
||||||
|
|
||||||
(defn get-by-filter [realm schema-name filter]
|
|
||||||
(-> realm
|
|
||||||
(.objects (name schema-name))
|
|
||||||
(.filtered filter)))
|
|
||||||
|
|
||||||
(defn- get-schema-by-name [opts]
|
(defn- get-schema-by-name [opts]
|
||||||
(->> opts
|
(->> opts
|
||||||
(mapv (fn [{:keys [name] :as schema}]
|
(mapv (fn [{:keys [name] :as schema}]
|
||||||
|
@ -219,7 +215,7 @@
|
||||||
(defmethod to-query :eq [schema schema-name _ field value]
|
(defmethod to-query :eq [schema schema-name _ field value]
|
||||||
(let [value (to-string value)
|
(let [value (to-string value)
|
||||||
field-type (field-type schema schema-name field)
|
field-type (field-type schema schema-name field)
|
||||||
escaped-value (when value (str/replace (str value) #"\"" "\\\""))
|
escaped-value (when value (gstr/escapeString (str value)))
|
||||||
query (str (name field) "=" (if (= "string" (name field-type))
|
query (str (name field) "=" (if (= "string" (name field-type))
|
||||||
(str "\"" escaped-value "\"")
|
(str "\"" escaped-value "\"")
|
||||||
value))]
|
value))]
|
||||||
|
|
Loading…
Reference in New Issue