On Sun, May 25, 2025 at 04:41:37PM -0400, Joe Wicentowski scripsit:
> Hi Graydon,

Hello!

> In the GUI have you tried running the command SET WRITEBACK=true in the
> command field? In my experience this is needed for XQuery Update
> expressions to persist.

In this particular case, I'm writing the DB back out to disk explicitly
using db:export(), and haven't had issues with persistence. (If I query
the DB after the updating expression it sure looks like the change is
really there, and I wouldn't want any automatic updates to the original
file version during the process I'm trying to implement.)

The problem was me partaking of the cabbage-nature, rather than anything
amiss with BaseX; the updating expression didn't specify the DB as part
of specifying the node, so it worked when the intended DB was the
context DB and didn't throw an error where some other DB was the context
DB because a previous step in the process had set a context DB. And I
was rather too focused on what I thought was happening to notice the
"previous step has set a context DB" part.

Having boiled the test case down far enough and trying it with a freshly
started instance of the BaseX GUI made this obvious when an error got
thrown about the context item. And then it's just a matter of sticking a
reference to the DB at the start of the XPath for the node in the
updating expression and everything works as intended.

I haven't found a mechanism to set or unset the context DB; I'd really
like one for writing queries with updating expressions particularly,
just so I can try to code around this kind of error.

-- Graydon

--  
Graydon Saunders  | [email protected]
Þæs oferéode, ðisses swá mæg.
-- Deor  ("That passed, so may this.")

Reply via email to