Giter Club home page Giter Club logo

Comments (16)

tonsky avatar tonsky commented on May 10, 2024 11

Phew. Issue from 2015. Finally implemented not/or/not-join/or-join in 0.17.1. Enjoy!

from datascript.

atroche avatar atroche commented on May 10, 2024 2

Hi guys,

I just posted a $USD300 bounty for this issue. Feel free to pitch in with cash or, y'know, claim the bounty =)

from datascript.

comnik avatar comnik commented on May 10, 2024 1

Sorry for reviving this, but I'd be up for taking a stab at this. @tonsky does it make more sense to wait for / contribute to query_v3 or add negation and disjunction to the current version of the query engine?

from datascript.

tonsky avatar tonsky commented on May 10, 2024

Sure, eventually :)

from datascript.

sparkofreason avatar sparkofreason commented on May 10, 2024

+1

from datascript.

bahulneel avatar bahulneel commented on May 10, 2024

Is there any progress on this as it would be extremely useful for me?

from datascript.

terinjokes avatar terinjokes commented on May 10, 2024

Disjoins seem to be implemented, at least as part of 0.15, but I can't get them to work. When I try the following code, adapted from test/query_or.cljc, I get the error "Query for unknown vars: [?e]".

var db = ds.db_with(ds.empty_db(), [
  {":db/id": 1, ":name": "Ivan", ":age": 10},
  {":db/id": 2, ":name": "Ivan", ":age": 20},
  {":db/id": 3, ":name": "Oleg", ":age": 10},
  {":db/id": 4, ":name": "Oleg", ":age": 20},
  {":db/id": 5, ":name": "Ivan", ":age": 10},
  {":db/id": 6, ":name": "Ivan", ":age": 20}
]);
ds.q('[:find ?e :where [(or [?e ":name" "Oleg"] [?e ":age" 10])]]', db);

Am I doing something wrong, or are "or"s still not ready?

from datascript.

bahulneel avatar bahulneel commented on May 10, 2024

There's an experimental query namespace called v3 that negation and joins work on, some other things don't though so your mileage may vary.

from datascript.

tonsky avatar tonsky commented on May 10, 2024

That’s right, it’s a rewrite of a query engine, it’s not used by default
because it doesn’t do rules, fn/pred calls and probably something else.

On Wed, Feb 24, 2016 at 2:44 PM Bahul Neel Upadhyaya <
[email protected]> wrote:

There's an experimental query namespace called v3 that negation and joins
work on, some other things don't though so your mileage may vary.


Reply to this email directly or view it on GitHub
#50 (comment).

from datascript.

bahulneel avatar bahulneel commented on May 10, 2024

If you just need a disjoint you can can the same effect with two rules with the same head.

from datascript.

terinjokes avatar terinjokes commented on May 10, 2024

As far as I can tell, query_v3 doesn't get exposed via the JS interop layer. Just to be clear, negation and disjoins only work in it?

@bahulneel Thanks, I saw disjoins were possible beforehand in the blog post linked above. I'm new to datalog (just started 12 hours ago or so), so haven't quite figured how to do write a or-equivalent rule just yet. I'll look into it today.

from datascript.

bahulneel avatar bahulneel commented on May 10, 2024

Based on your example you could create a rule called (name-or-age ?name ?age) with two bodies e.g.:

[[(name-or-age ?e ?name ?age)
  [?e :name ?name]]
 [(name-or-age ?e ?name ?age)
  [?e :age ?age]]]

Then in the query:

ds.q('[:find ?e :in $ % :where (name-or-age ?e "Oleg" 10)]', db, rules);

(not sure what the js native way of making the rules data structure is)

from datascript.

terinjokes avatar terinjokes commented on May 10, 2024

@bahulneel You put it in quotes like that. 😄

from datascript.

tonsky avatar tonsky commented on May 10, 2024

As far as I can tell, query_v3 doesn't get exposed via the JS interop
layer. Just to be clear, negation and disjoins only work in it?

Yes. It’s not considered part of DS API in Clojure either. It’s just where
development happens.

On Wed, Feb 24, 2016 at 11:26 PM Terin Stock [email protected]
wrote:

@bahulneel https://github.com/bahulneel You put it in quotes like that. [image:
😄]


Reply to this email directly or view it on GitHub
#50 (comment).

from datascript.

bahulneel avatar bahulneel commented on May 10, 2024

I've shown a method of achieving both using some custom predicates in this ticket: #238

from datascript.

tonsky avatar tonsky commented on May 10, 2024

I doubt I’ll be able to revive query_v3 any time soon, so more realistic approach would be to add those to the current query impl

from datascript.

Related Issues (20)

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.