diff options
-rw-r--r-- | acf2/model/node.lua | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/acf2/model/node.lua b/acf2/model/node.lua index e4b843b..2d9aa98 100644 --- a/acf2/model/node.lua +++ b/acf2/model/node.lua @@ -115,11 +115,18 @@ function M.TreeNode:init(context, dtype) end function M.TreeNode:fetch(path, create) - if type(path) == 'string' then path = pth.split(path) end + local mt = getmetatable(self) + + if type(path) == 'string' then + if pth.is_absolute(path) and mt.path > '/' then + assert(not create) + return mt.txn:fetch(path) + end + path = pth.split(path) + end if #path == 0 then return self end - local mt = getmetatable(self) local name = path[1] if not mt.member(name) then raise(mt.path, 'Member does not exist: '..name) |