Skip to content

Commit

Permalink
fix bug with date insert
Browse files Browse the repository at this point in the history
  • Loading branch information
stopachka committed Dec 31, 2024
1 parent 835a282 commit ecfa74b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
9 changes: 8 additions & 1 deletion server/src/instant/db/model/triple.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
[instant.util.string :refer [multiline->single-line]]
[instant.util.tracer :as tracer])
(:import
(java.util UUID)))
(java.util UUID)
(java.time Instant)))

;; (XXX): Currently we allow value to be nil
;; In the future, we may want to _retract_ the triple if the value is nil
Expand Down Expand Up @@ -706,3 +707,9 @@
(inc i)))))))
(tracer/add-data! {:attributes {:total-count @row-count}})
{:row-count @row-count})))

(defn parse-date-value [x]
(cond (string? x)
(Instant/parse x)
(number? x)
(Instant/ofEpochMilli x)))
10 changes: 7 additions & 3 deletions server/src/instant/reactive/invalidator.clj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
[instant.reactive.store :as rs]
[instant.util.async :as ua]
[instant.util.json :refer [<-json]]
[instant.util.tracer :as tracer])
[instant.util.tracer :as tracer]
[instant.db.model.triple :as triple-model])
(:import (java.util UUID)))

(declare wal-opts)
Expand Down Expand Up @@ -43,10 +44,13 @@
e (UUID/fromString (:entity_id m))
a (UUID/fromString (:attr_id m))
v-parsed (<-json (:value m))
v (if (:eav m)
v (cond
(:eav m)
(UUID/fromString v-parsed)
(= (:checked_data_type m) "date")
(triple-model/parse-date-value v-parsed)
:else
v-parsed)

ks (->> #{:ea :eav :av :ave :vae}
(filter m))]
(map (fn [k] [k #{e} #{a} #{v}])
Expand Down

0 comments on commit ecfa74b

Please sign in to comment.