Behaviour of db:open('mydb') update {} in updating functions
Friday, 22 July 2016 · 2 messages
MG
Maximilian Gärber22 Jul 2016 12:17 #
Hi,
I just noticed that when I use a db that is opened this way, I cannot do updates anymore.
Example:
declare variable $_:PUB := db:open('PUB') update {};
Then, inside updating function:
let $sec := $_:PUB//Section[@Guid = $id]
return replace node trace($sec) with <Section>changed</Section>There is no error whatsoever, the update simply doesnt happen. (BaseX 8.4.4)
Bug?
Regards,
Max
DK
Dirk Kirsten22 Jul 2016 12:28 #
Hi Max,
I just copied it in my BaseX instance and it (imho correctly) returned the error message "Copy expression is incomplete" as "update {}" is invalid (if you want to update nothing it should be an empty sequence).
However, given this works I would not be surprised if this does not update the database. As you probably know "update" is just a more convenient way of using the copy/modify/transform espression. However, this will not update the original element, but instead create a copy and update this.
So I would expect your variable $_:PUB to hold a main memory copy of the database and this variable will be modified, i.e. your original database will remain the same.
Hope this helps, Dirk
Quoted text · Maximilian Gärber · 20 lines
On 07/22/2016 12:17 PM, Maximilian Gärber wrote: > Hi, > > I just noticed that when I use a db that is opened this way, I cannot > do updates anymore. > > Example: > declare variable $_:PUB := db:open('PUB') update {}; > > Then, inside updating function: > > let $sec := $_:PUB//Section[@Guid = $id] > return replace node trace($sec) with <Section>changed</Section> > > There is no error whatsoever, the update simply doesnt happen. (BaseX 8.4.4) > > Bug? > > Regards, > Max
--
Dirk Kirsten, BaseX GmbH, http://basexgmbh.de
|-- Firmensitz: Blarerstrasse 56, 78462 Konstanz
|-- Registergericht Freiburg, HRB: 708285, Geschäftsführer:
| Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 91 68 276, Fax: 0049 7531 20 05 22
Written for BaseX 8.5. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery