Consider the following xquery on "db2":
for $doc in db:open('db2')
return $doc
with the following code
//start session
static ClientSession session;
session = new ClientSession("localhost", 1984, "admin", "admin");
session.execute(new Check(db1));
//query
ClientQuery query = session.query(xquery);
result = query.execute();
query.close();
This code will execute, but with an empty result. This is because within
the session only db1 is opened and I am querying db2. When explicit opening
(session.execute(new Open(db2)); ) it returns the expected value of course.
Do you agree that this can be confusing?
I would expect that the xquery in combination with the above code returns
1) an error that quering db2 while it's not opened in the session
or
2) that "db:open('db2')" in the xquery performs implicitly a
session.execute(new Open(db2), so that it automatically switches to db2.