Module:Lorebook/Debug: Difference between revisions

No edit summary
Add debug output to list all keys in row table to identify correct property key names
Line 78: Line 78:
local function normalizeValue(val)
local function normalizeValue(val)
   if type(val) == 'table' then
   if type(val) == 'table' then
     return val[1]
     return val[1] or ''
   end
   end
   return val
   return val or ''
end
end


Line 107: Line 107:
       debug_info = debug_info .. "Raw row.primary: " .. tostring(row.primary) .. " (type: " .. type(row.primary) .. ")\n"
       debug_info = debug_info .. "Raw row.primary: " .. tostring(row.primary) .. " (type: " .. type(row.primary) .. ")\n"
       debug_info = debug_info .. "Raw row['Primary keys']: " .. tostring(row['Primary keys']) .. " (type: " .. type(row['Primary keys']) .. ")\n"
       debug_info = debug_info .. "Raw row['Primary keys']: " .. tostring(row['Primary keys']) .. " (type: " .. type(row['Primary keys']) .. ")\n"
     
      -- List all keys in the row table
      debug_info = debug_info .. "\nAll keys in row:\n"
      for k, v in pairs(row) do
        debug_info = debug_info .. "  [" .. tostring(k) .. "] = " .. tostring(v) .. " (type: " .. type(v) .. ")\n"
      end
     
       -- Store debug info in a global to access later
       -- Store debug info in a global to access later
       _G._debug_row_info = debug_info
       _G._debug_row_info = debug_info