diff options
Diffstat (limited to 'acf2')
-rw-r--r-- | acf2/model/field.lua | 6 | ||||
-rw-r--r-- | acf2/model/node.lua | 9 |
2 files changed, 9 insertions, 6 deletions
diff --git a/acf2/model/field.lua b/acf2/model/field.lua index 4307f6f..309249e 100644 --- a/acf2/model/field.lua +++ b/acf2/model/field.lua @@ -271,9 +271,9 @@ end function M.TreeNode:load(context, options) if context.txn and not ( - ( - options and options.create - ) or self.create or self:_load(context) + util.setdefault( + options or {}, 'create', self.create + ) or self:_load(context) ) then return end return self.itype(context, self.iparams) end diff --git a/acf2/model/node.lua b/acf2/model/node.lua index d0d44cd..85a857d 100644 --- a/acf2/model/node.lua +++ b/acf2/model/node.lua @@ -125,8 +125,11 @@ function M.TreeNode:fetch(path, create) raise(mt.path, 'Member does not exist: '..name) end - local options = {create=create} - if create and #path == 1 then options.dereference = false end + local options = {} + if create then + options.create = true + if #path == 1 then options.dereference = false end + end local next = mt.get(name, options) if next == nil and (not create or #path > 1) then raise(mt.path, 'Subordinate does not exist: '..name) @@ -332,7 +335,7 @@ end local function _ipairs(mt, i) i = i + 1 - local v = mt.load(i) + local v = mt.load(i, {create=false}) if v == nil then return end return i, v end |