Eugene Trifuntov
2015-03-09 12:01:05 UTC
Hello,
I have two valid queries:
user=> (d/q '[:find ?e :where [?e :user/username "username1"]] (d/db conn))
#{[17592186045418]}
user=> (d/q '[:find ?e :where [?e :user/username "username2"]] (d/db conn))
#{[17592186045509]}
Now I want the query that will be logical disjunction of the two above, id
est find all entities having "username1" OR "username2" in :user/username.
Following datomic docs I am building query like:
(d/q '[:find ?e :where (or [?e :user/username "username1"] [?e
:user/username "username2"])] (d/db conn))
which throws: CompilerException java.lang.RuntimeException: Unable to
resolve symbol: ?e in this context
This exception is strange by itself, because whole query is quoted and I
have no idea why clojure tries to evaluate it anyway, but it's not the
question. When I am trying to feed the query to console it also looks
strange.
1. Inside query textarea the query converted to:
[:find ?e
:where
["or" [?e :user/username "username1"] [?e :user/username "username2"]]
]
2. Following error issued: message: processing clause: ["or" [?e
:user/username "username1"] [?e :user/username "username2"]], message:
:db.error/invalid-lookup-ref Invalid list form: [?e :user/username
"username2"]
My questions are:
1. What's the proper syntax for query I'd like to build?
2. Since I'm gonna build it programmatically what is proper map form for
such query?
I have two valid queries:
user=> (d/q '[:find ?e :where [?e :user/username "username1"]] (d/db conn))
#{[17592186045418]}
user=> (d/q '[:find ?e :where [?e :user/username "username2"]] (d/db conn))
#{[17592186045509]}
Now I want the query that will be logical disjunction of the two above, id
est find all entities having "username1" OR "username2" in :user/username.
Following datomic docs I am building query like:
(d/q '[:find ?e :where (or [?e :user/username "username1"] [?e
:user/username "username2"])] (d/db conn))
which throws: CompilerException java.lang.RuntimeException: Unable to
resolve symbol: ?e in this context
This exception is strange by itself, because whole query is quoted and I
have no idea why clojure tries to evaluate it anyway, but it's not the
question. When I am trying to feed the query to console it also looks
strange.
1. Inside query textarea the query converted to:
[:find ?e
:where
["or" [?e :user/username "username1"] [?e :user/username "username2"]]
]
2. Following error issued: message: processing clause: ["or" [?e
:user/username "username1"] [?e :user/username "username2"]], message:
:db.error/invalid-lookup-ref Invalid list form: [?e :user/username
"username2"]
My questions are:
1. What's the proper syntax for query I'd like to build?
2. Since I'm gonna build it programmatically what is proper map form for
such query?
--
You received this message because you are subscribed to the Google Groups "Datomic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to datomic+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Datomic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to datomic+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.