webmcp
changeset 532:257dd2933ab2
Avoid including duplicate IDs when fetching referenced records
author | jbe |
---|---|
date | Mon Mar 12 13:00:19 2018 +0100 (2018-03-12) |
parents | b19a6b4f61f3 |
children | b316f1c894ae |
files | libraries/mondelefant/mondelefant.lua |
line diff
1.1 --- a/libraries/mondelefant/mondelefant.lua Mon Jan 15 20:13:32 2018 +0100 1.2 +++ b/libraries/mondelefant/mondelefant.lua Mon Mar 12 13:00:19 2018 +0100 1.3 @@ -1521,11 +1521,15 @@ 1.4 local options = options or {} 1.5 local model = get_model() 1.6 -- TODO: too many records cause PostgreSQL command stack overflow 1.7 + local ids_used = {} 1.8 local ids = { sep = ", " } 1.9 for i, object in ipairs(list) do 1.10 local id = object[this_key] 1.11 if id ~= nil then 1.12 - ids[#ids+1] = {"?", id} 1.13 + if not ids_used[id] then 1.14 + ids[#ids+1] = {"?", id} 1.15 + ids_used[id] = true 1.16 + end 1.17 end 1.18 end 1.19 if #ids == 0 then