Module:CargoQuery: Difference between revisions

no edit summary
(make getColNames private)
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
local PARAM_LOOKUP = {
local PARAM_LOOKUP = {
['order by'] = 'orderBy',
['order by'] = 'orderBy',
join = 'join',
['join on'] = 'join',
['join on'] = 'join',
['group by'] = 'groupBy',
['group by'] = 'groupBy',
Line 15: Line 14:
local intro = frame:preprocess(args.intro or '')
local intro = frame:preprocess(args.intro or '')
local outro = frame:preprocess(args.outro or '')
local outro = frame:preprocess(args.outro or '')
local template = frame:preprocess(args.template or 'single query result')
local delimiter = args.delimiter or ''
local delimiter = args.delimiter or ''
Line 30: Line 30:
for i, row in ipairs(result) do
for i, row in ipairs(result) do
row.index = i
row.index = i
tbl[#tbl+1] = frame:expandTemplate{ title = args.template, args = row }
tbl[#tbl+1] = frame:expandTemplate{ title = template, args = row }
end
end
if colcount ~= nil then
if colcount ~= nil then
Line 181: Line 181:
template = frame:preprocess(args['template'] or '')
template = frame:preprocess(args['template'] or '')
if template == nil or template == '' then
if template == nil or template == '' then
     error('A template must be specified!')
     template='single query result'
end
end
delimiter = frame:preprocess(args['delimiter'] or '')
delimiter = frame:preprocess(args['delimiter'] or '')