Skip to content

Duplicate flow not accounted for in tracked change results #63

@wotbrew

Description

@wotbrew
Owner

The problem @isaksky (🙏 ) raised on slack involves duplication in the tracked :added / :deleted vectors.

I think :added & :deleted might want to be sets as duplicates during flow are permitted, unless there is some otherway to distinct the adds during tracking.

(let [num-schema [[:from :nums]
                    [:constrain
                     [:check [number? :n]]
                     [:unique :id]]]
        watched-query (into num-schema
                        [[:where [= :id 1]
                          ;; Try removing this form, the second entry in the result vector does not appear without it
                          [< 1 [rel/env :now]]]
                         [:extend
                          [:hm [- :n [rel/env :now]]]]])
        db (-> (rel/transact {}
                 (for [i (range 1 1e2)]
                   [:insert :nums {:id i, :n i}]))
             (rel/with-env {:now (inst-ms (java.time.Instant/now))})
             (rel/mat num-schema)
             (rel/watch watched-query))]
    (->> (get-in
           (rel/track-transact
             db
             (rel/set-env-tx {:now (+ (inst-ms (java.time.Instant/now)) 5)}))
           [:changes watched-query :added])))
;; => 
[{:id 1, :n 1, :hm -1701901820800} {:id 1, :n 1, :hm -1701901820800}]           

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @wotbrew

        Issue actions

          Duplicate flow not accounted for in tracked change results · Issue #63 · wotbrew/relic