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.
Hi Raymond,
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'm not 100% sure how you proceeded. I’ve added another example, which returns "<a/>" as result..
ClientSession session = new ClientSession("localhost", 1984, "admin", "admin"); session.execute(new CreateDB("db1", "<a/>")); session.execute(new CreateDB("db2", "<b/>"));
ClientQuery query = session.query("db:open('db1')"); System.out.println(query.execute()); query.close();
Does this conform to your expectations?
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.
Such a decision could lead to various new questions, because XQuery allows much more databases to be opened in a single query. What would you e.g. expect the following XQuery to do?
for $d in 1 to 5 let $db := db:open($d) return $db//results
..or yet another example:
db:create( "newdb", db:open("olddb") )
Best, Christian ___________________________
I would expect that the xquery in combination with the above code returns
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
basex-talk@mailman.uni-konstanz.de