Editing Module:BucketGet

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision Your text
Line 369: Line 369:
end
end


-- Make missing split values genuinely empty.
row[spec.alias .. i] = val or ""
if val == nil or val == false then
val = ""
elseif type(val) == "string" then
val = mw.text.trim(val)
end
 
row[spec.alias .. i] = val
end
end
end
end
Line 488: Line 481:
local function normalizeUserformatValue(value)
local function normalizeUserformatValue(value)
-- Missing values.
-- Missing values.
if value == nil or value == false then
if value == nil then
return ''
end
 
-- Boolean false should not become "false".
if value == false then
return ''
return ''
end
end
Line 500: Line 498:
local s = mw.text.trim(tostring(v))
local s = mw.text.trim(tostring(v))


-- Ignore empty/null array entries.
if s ~= '' then
local lower = mw.ustring.lower(s)
 
if s ~= ''
and lower ~= 'null'
and lower ~= 'nil'
and lower ~= 'false'
and lower ~= '<i>null</i>' then
 
table.insert(values, s)
table.insert(values, s)
end
end
Line 520: Line 510:
value = mw.text.trim(tostring(value))
value = mw.text.trim(tostring(value))


-- Treat all common empty/null representations as empty.
-- Treat common null representations as empty.
local lower = mw.ustring.lower(value)
local lower = mw.ustring.lower(value)


Line 526: Line 516:
or lower == 'null'
or lower == 'null'
or lower == 'nil'
or lower == 'nil'
or lower == 'false'
or lower == 'false' then
or lower == '<i>null</i>' then


return ''
return ''
end
end


-- Remove non-breaking spaces.
-- Remove non-breaking spaces if a bucket value happens
-- to contain them.
value = value:gsub('\194\160', ' ')
value = value:gsub('\194\160', ' ')


Line 559: Line 549:
for _, col in ipairs(columns) do
for _, col in ipairs(columns) do
local value =
local value =
normalizeUserformatValue(
normalizeUserformatValue(row[col.alias])
row[col.alias]
)


local placeholder =
local placeholder =
Line 822: Line 810:
local value = row[fmt_info.column]
local value = row[fmt_info.column]


-- Empty values stay empty.
if value == nil then
if value == nil
value = ''
or value == false
or (
type(value) == "string"
and mw.text.trim(value) == ""
)
or (
type(value) == "string"
and mw.ustring.lower(
mw.text.trim(value)
) == "<i>null</i>"
) then
 
row[fmt_info.column] = ''


elseif type(value) == "table" then
elseif type(value) == "table" then
Line 842: Line 817:


for _, v in ipairs(value) do
for _, v in ipairs(value) do
local clean = v
local formatted =
 
fmt_info.format:gsub(
if clean == nil or clean == false then
"%%s",
clean = ""
function()
elseif type(clean) == "string" then
return v or ''
clean = mw.text.trim(clean)
end
end
 
local lower =
mw.ustring.lower(
tostring(clean)
)
)


if clean ~= ""
table.insert(
and lower ~= "null"
formatted_values,
and lower ~= "nil"
formatted
and lower ~= "false"
)
and lower ~= "<i>null</i>" then
 
local formatted =
fmt_info.format:gsub(
"%%s",
function()
return clean
end
)
 
table.insert(
formatted_values,
formatted
)
end
end
end


Line 1,909: Line 1,864:
if group_by_str then
if group_by_str then
local group_by_cols =
local group_by_cols =
parseGroupBy(group_by_str)
parseGroupBy(
group_by_str
)


local agg_specs =
local agg_specs =
Please note that all contributions to The Petit Planet Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see Petit Planet Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)
Preview page with this template
Below are commonly used wikitext from MediaWiki:Edittools. Click on any to insert them in the edit box.
File Pages==Summary====Licensing=={{Fairuse}}{{File|}}
Dynamic Page List¦²«»²{¦}²«»«/»«!----»
Array in DPL¹^2{}^2^2{¹}^2
Parser Functions{{#if:||}}
{{#ifeq:|||}}
{{#expr:}}
{{#switch:||#default=}}
{{#replace:||}}
{{#titleparts:}}
{{#tag:|}}
Markup{{}}|[][[]][[Category:]]#REDIRECT [[]] [[Category:Redirect Pages]]<code></code><includeonly></includeonly><noinclude></noinclude><nowiki></nowiki><!----><br>§
Notices{{Stub|}}{{Stub Dialogue}}{{Upcoming}}{{Under Construction}}{{Placeholder|}}
Magic Words{{!}}{{formatnum:}}{{lc:}}{{uc:}}{{PAGENAME}}{{FULLPAGENAME}}{{ROOTPAGENAME}}{{BASEPAGENAME}}{{SUBPAGENAME}}{{DISPLAYTITLE:|noreplace}}__TOC____NOTOC____EXPECTUNUSEDCATEGORY____HIDDENCAT__
HTML Entities&mdash;&nbsp;&comma;&shy;