Welcome! Please see the About page for a little more info on how this works.

+2 votes
in On-Prem by
edited by

Hi, when I'm executing query in repl in such way:

(d/q "[:find
 [?Post ...]
 :in
 $
 $comment
 [?Post_value_0 ...]
 :where

[?Post :IModel/typeName ?Post_value_0]
(or-join 
 [?Post ?Comment_text_value_3]

 [(datomic.api/q
   \"[:find [?Comment_uid_2 ...] :in $ :where 
   [?Comment_by_text_1 :Comment/text _]
   [?Comment_by_text_1 :IModel/uid ?Comment_uid_2]
   ]\"
   $comment)
  [?Comment_uid_2 ...]]

  [(datomic.api/q
   \"[:find [?Comment_uid_2 ...] :in $ :where 
   [?Comment_by_text_1 :Comment/text _]
   [?Comment_by_text_1 :IModel/uid ?Comment_uid_2]
   ]\"
   $comment)
  [?Comment_uid_2 ...]]

)
 [?Post :Post/comments ?Comment_uid_2]
]
" (d/db conn) (d/db connComment) #{"Post"})

The next error is returned:
:db.error/not-an-entity Unable to resolve entity: :Comment/text

My supposing is that query inside datomic.api/q is executed for database returned by (d/db conn) but not (d/db connComment) because if I create :Comment/text for the first database from input list then query is executed without errors.

If to avoid or-join and execute the query in the next way:

(d/q "[:find
 [?Post ...]
 :in
 $
 $comment
 [?Post_value_0 ...]
 :where

[?Post :IModel/typeName ?Post_value_0]
 [?Post ?Comment_text_value_3]

 [(datomic.api/q
   \"[:find [?Comment_uid_2 ...] :in $ :where 
   [?Comment_by_text_1 :Comment/text _]
   [?Comment_by_text_1 :IModel/uid ?Comment_uid_2]
   ]\"
   $comment)
  [?Comment_uid_2 ...]]

  [(datomic.api/q
   \"[:find [?Comment_uid_2 ...] :in $ :where 
   [?Comment_by_text_1 :Comment/text _]
   [?Comment_by_text_1 :IModel/uid ?Comment_uid_2]
   ]\"
   $comment)
  [?Comment_uid_2 ...]]


 [?Post :Post/comments ?Comment_uid_2]
]
" (d/db conn) (d/db connComment) #{"Post"})

then query is executed without errors.

Datamic on prem 0.9.6.* version

Please log in or register to answer this question.

...