Coder Social home page Coder Social logo

or-join too strict? about datalog-parser HOT 2 CLOSED

xificurC avatar xificurC commented on July 26, 2024
or-join too strict?

from datalog-parser.

Comments (2)

xificurC avatar xificurC commented on July 26, 2024

Just to have that datomic example noted:

(require '[datomic.api :as db])
(def c (db/connect (doto "datomic:free://localhost:4334/mydb?password-datomic" db/create-database)))
(db/transact c [{:db/ident :id :db/valueType :db.type/keyword :db/cardinality :db.cardinality/one :db/unique :db.unique/identity} {:db/ident :n :db/valueType :db.type/long :db/cardinality :db.cardinality/one}])
(db/transact c [{:id 1 :n 1} {:id 2}])
(db/q '[:find (pull ?e [*]) :in $ ?max :where [?e :id ?id] (or-join [?e ?max] (not [?e :n _]) (and [?e :n ?n] [(< ?n ?max)]))] (db/db c) 1000)
;; =>
[[{:db/id 17592186245422, :id :b}] [{:db/id 17592186245421, :id :a, :n 1}]]

from datalog-parser.

whilo avatar whilo commented on July 26, 2024

I think this is an ambiguity in the Datomic specification:

An or-join clause allows you to specify which variables should unify with the surrounding clause; only this list of variables needs binding before the clause can run.

https://docs.datomic.com/on-prem/query.html#building-queries-programmatically

Our parser has interpreted the "should" unify to mean that these variables should also exist in the clauses and unify between them and the outside. Datomic on the other hand says that it will make sure that these variables are bound before the clause is run (a guarantee that we do not make yet), while it seems permissive if they are not being used. I have changed our behavior. The issue is fixed in datalog-parser 0.1.3 in 85a3ca1.

Please open further issues if you experience more inconsistencies.

from datalog-parser.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.