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

:db.fn/call behavior #366

Closed
souenzzo opened this issue Sep 30, 2020 · 2 comments
Closed

:db.fn/call behavior #366

souenzzo opened this issue Sep 30, 2020 · 2 comments

Comments

@souenzzo
Copy link

On datomic, when we call a "transaction function", the db that this function receive is the db before all transaction

In datascript 1.0.1, it receive a "partial db" relative to it's position in transaction

This behavior should be documented ?!

(let [conn (ds/create-conn)]
  (ds/transact! conn [[:db.fn/call println]
                      {:a 42}
                      [:db.fn/call println]
                      {:b 24}
                      [:db.fn/call println]]))
=>
#datascript/DB {:schema nil, :datoms []}
#datascript/DB {:schema nil, :datoms [[1 :a 42 536870913]]}
#datascript/DB {:schema nil, :datoms [[1 :a 42 536870913] [2 :b 24 536870913]]}
@tonsky
Copy link
Owner

tonsky commented Sep 30, 2020

Yes. Are you willing to provide a PR for e.g. README.md?

@refset
Copy link
Contributor

refset commented May 16, 2024

Just an FYI that the Datomic Jepsen report discusses this distinction, and Stu elaborated on the reasoning here: https://news.ycombinator.com/item?id=40373311

It is worth noting here that Datomic's intra-transaction semantics are not a decision made in isolation, they emerge naturally from the information model.
Everything in a Datomic transaction happens atomically at a single point in time. Datomic transactions are totally ordered, and this ordering is visible via the time t shared by every datom in the transaction. These properties vastly simplify reasoning about time.
With this information model intermediate database states are inexpressible. Intermediate states cannot all have the same t, because they did not happen at the same time. And they cannot have different ts, as they are part the same transaction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants