diff options
Diffstat (limited to 'acf/transaction/init.lua')
-rw-r--r-- | acf/transaction/init.lua | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/acf/transaction/init.lua b/acf/transaction/init.lua index a76e7bf..76a8d47 100644 --- a/acf/transaction/init.lua +++ b/acf/transaction/init.lua @@ -6,7 +6,7 @@ See LICENSE file for license details module(..., package.seeall) local ErrorDict = require('acf.error').ErrorDict -local RootModel = require('acf.model.root').RootModel +local root = require('acf.model.root') local object = require('acf.object') local pth = require('acf.path') local be_mod = require('acf.transaction.backend') @@ -46,7 +46,7 @@ function Transaction:init(backend, validate) self.validate = validate self.validable = {} - self.root = RootModel(self) + self.root = root.RootModel(self) end function Transaction:check() @@ -94,6 +94,20 @@ function Transaction:_set_multiple(mods) local delete = value == nil + if delete then + -- assume one-level refs for now + local top = root.topology(ppath) + if top then + local errors = ErrorDict() + for _, refs in ipairs(top.referrers) do + for _, ref in ipairs(self.root:search_refs(refs)) do + errors:collect(ref.deleted, ref, path) + end + end + errors:raise() + end + end + if type(old) == 'table' then if delete then for _, child in ipairs(old) do self:set(pth.join(path, child)) end |