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

Duplicate flow not accounted for in tracked change results #63

Open
wotbrew opened this issue Dec 8, 2023 · 0 comments
Open

Duplicate flow not accounted for in tracked change results #63

wotbrew opened this issue Dec 8, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@wotbrew
Copy link
Owner

wotbrew commented Dec 8, 2023

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}]           
@wotbrew wotbrew added the bug Something isn't working label Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant