Order of variables matters when attributes are passed as arguments

Lets consider the next schema and example data:

(def user-schema [
                    {
                      :db/ident :user/kind
                      :db/valueType :db.type/string
                      :db/cardinality :db.cardinality/one
                   }
                   {
                       :db/ident :user/name.EN
                       :db/valueType :db.type/string
                       :db/cardinality :db.cardinality/one
                   }
                   {
                       :db/ident :user/name.ES
                       :db/valueType :db.type/string
                       :db/cardinality :db.cardinality/one
                   }

                   ])
(d/transact conn user-schema)

(def user-data [
  {
    :user/kind "owner"
    :user/name.EN "Boby"
    :user/name.ES "Doby"
  }
  {
    :user/kind "owner"
    :user/name.EN "Doby"
    :user/name.ES "Boby"
  }
  {
    :user/kind "owner"
    :user/name.EN "Mobi"
    :user/name.ES "Tobi"
  }
])
(d/transact conn user-data)

I want to search for any entity which has either name.EN or name.ES equal to Doby.

(d/q "[
:find ?user 
:in $ ?userKind [?userNameValues ...] [?userNameAttrs ...] 
:where 
  [?user :user/kind ?userKind]
  [?user ?userNameAttrs ?userNameValues]
]"
(d/db conn), "owner" ["Doby"] [:user/name.EN :user/name.ES] )

The result of query is empty

But if to swap ?userNameValues and ?userNameAttrs then all works:

(d/q "[
:find ?user 
:in $ ?userKind [?userNameAttrs ...] [?userNameValues ...]
:where 
[?user :user/kind ?userKind]
[?user ?userNameAttrs ?userNameValues]
]"
(d/db conn), "owner" [:user/name.EN :user/name.ES] ["Doby"] )

#{[17592186045629] [17592186045630]}

As you see two elements were returned. What is more interesting, the first query works when to remove the first condition:

(d/q "[
:find ?user 
:in $ ?userKind [?userNameValues ...] [?userNameAttrs ...] 
:where 
  [?user ?userNameAttrs ?userNameValues]
]"
(d/db conn), "owner" ["Doby"] [:user/name.EN :user/name.ES] )

#{[17592186045629] [17592186045630]}

What version of Datomic are you using?
Are you using the client of the peer api?

I was able to make a simple reproduction of this approach and did not see the same problem.

I made an adjustment and was able to reproduce the behavior you’re seeing.
We will investigate.