From ecfa74be6560fc361daecfdfd72e036a256818d3 Mon Sep 17 00:00:00 2001 From: stopachka Date: Tue, 31 Dec 2024 10:53:03 -0500 Subject: [PATCH] fix bug with date insert --- server/src/instant/db/model/triple.clj | 9 ++++++++- server/src/instant/reactive/invalidator.clj | 10 +++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/server/src/instant/db/model/triple.clj b/server/src/instant/db/model/triple.clj index cfefd81d6..621a96375 100644 --- a/server/src/instant/db/model/triple.clj +++ b/server/src/instant/db/model/triple.clj @@ -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 @@ -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))) diff --git a/server/src/instant/reactive/invalidator.clj b/server/src/instant/reactive/invalidator.clj index c1ca4e050..35ed26598 100644 --- a/server/src/instant/reactive/invalidator.clj +++ b/server/src/instant/reactive/invalidator.clj @@ -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) @@ -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}])