Comments (16)
Phew. Issue from 2015. Finally implemented not/or/not-join/or-join in 0.17.1. Enjoy!
from datascript.
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.
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.
Sure, eventually :)
from datascript.
+1
from datascript.
Is there any progress on this as it would be extremely useful for me?
from datascript.
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.
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.
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.
If you just need a disjoint you can can the same effect with two rules with the same head.
from datascript.
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.
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.
@bahulneel You put it in quotes like that. 😄
from datascript.
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.
I've shown a method of achieving both using some custom predicates in this ticket: #238
from datascript.
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)
- Cannot compare xxx to xxx HOT 4
- Difference in pull query output between 1.0.1 and 1.3.11 HOT 3
- :db/cas should take a function HOT 3
- Nil values when building clojurescript for chrome extension HOT 3
- equality on ^Entity bypasses db HOT 3
- Improve Skypack "Package Score" for better devX HOT 2
- Attribute of composite tuple starting with colon is not working in js HOT 1
- How to hotfix aot code ?
- How to hot fix aot code?
- Rules - Required bindings doesn't evaluate correctly HOT 1
- Datascript101 link is dead HOT 1
- `get-else` fails when passed a lookup.
- `entity` returns entities for ids that don't exist HOT 2
- Is there any doc to demo idiom way to implement pagination in datascript? HOT 4
- Upsert of datom with composite tuple containing lookup ref fails HOT 5
- Recursive reverse lookups not working quite like it should HOT 1
- Lookup ref in composite tuple during upsert HOT 1
- do we have double vector type? HOT 2
- `:xform` is not called on ref attributes HOT 2
- Query performance with rules is much worse than "equivalent" inline clause HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datascript.