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

passing more than one source (value) argument to Diametric::Persistence::Peer.q #59

Open
siemionides opened this issue Oct 8, 2014 · 2 comments

Comments

@siemionides
Copy link
Contributor

Hello,
since I'm posting a lot you can expect me to become Diametric master and Diametric well documented library with nice FAQ ;)

I've been struggling with passing more than one argument to Diametric::Persistence::Peer.q method.
Let's say I have a following code:

qString = "
[:find ?e
 :in $ [?badge_name ...]
 :where
 [?e :badge/name ?badge_name]
]

"
It's crucial here that I use collection [?t ...] (I need to create simple OR statetent and retrieve all he Badges that has a name that exist in the set specified by me).

I'm calling it through, eg.

result = Diametric::Persistence::Peer.q(qString, @conn.db, ['facebook_is_fan', 'facebook_engagement_gold', 'average_weekly_revenue'])

Works as expected. However, if I add additional source argument into my query string:

qString = "
[:find ?e
 :in $ ?badge_value [?badge_name ...]
 :where
 [?e :badge/value ?badge_value]
 [?e :badge/name ?badge_name]
]

"
I cannot come up with a way of adding additional parameter as source argument.
For instance,

result = Diametric::Persistence::Peer.q(qString, @conn.db, [[30.42], ['facebook_is_fan', 'facebook_engagement_gold', 'average_weekly_revenue']])

Returns

RuntimeError: Datomic Exception: :db.error/too-few-inputs Query expected 3 inputs but received 2
   q at diametric/DiametricPeer.java:295

Isn't it caused by implementation of q() method that contains the call for Diametric::Persistence::Peer.q(query, db, args.flatten(1)) and the call for Clojure APi should not expect only flattened list of source aguments?

I'd like to achieve sth like the suggested response for this issue https://groups.google.com/forum/?hl=pl#!topic/datomic/QZJrpbp-t-8

Thanks in advanve!

@yokolet
Copy link
Contributor

yokolet commented Oct 9, 2014

This may be a bug, also. But, from a query string, the argument should be two in addition to @conn.db. So, query will be

result = Diametric::Persistence::Peer.q(qString, @conn.db, [30.42], ['facebook_is_fan', 'facebook_engagement_gold', 'average_weekly_revenue'])

@siemionides
Copy link
Contributor Author

So if go like this and I have this query string:

qString = "
[:find ?e
 :in $ ?badge_value [?badge_name ...]
 :where
 [?e :badge/name ?badge_name]
]"

Firstly, the rubyMine is warning me about wrong nr of arguments:
https://www.dropbox.com/s/ddtgi55tzgo610n/Screenshot%202014-10-10%2010.36.40.png?dl=0

Seconly, im being given RuntimeError:

RuntimeError: Datomic Exception: :db.error/too-few-inputs Query expected 3 inputs but received 2
   q at diametric/DiametricPeer.java:295
  testC at test.rb:65
 (root) at test.rb:82

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

2 participants