831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
|
local con = symbol(&lib.pq.PGconn)
local function sqlsquash(s) return s
:gsub('%%include (.-)%%',function(f)
return sqlsquash(lib.util.ingest('backend/schema/' .. f))
end) -- include dependencies
:gsub('%-%-.-\n','') -- remove disruptive line comments
:gsub('%-%-.-$','') -- remove unnecessary terminal comments
:gsub('<(%g-)>',function(r) return tostring(sqlvars[r]) end)
:gsub('%s+',' ') -- remove whitespace
:gsub('^%s*(.-)%s*$','%1') -- chomp
end
-- to simplify queries and reduce development headaches in general, we
-- offload as much logic as possible into views. to avoid versioning
-- difficulties, these views are not part of the schema, but are rather
|
|
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
|
local con = symbol(&lib.pq.PGconn)
local function sqlsquash(s) return s
:gsub('%%include (.-)%%',function(f)
return sqlsquash(lib.util.ingest('backend/schema/' .. f))
end) -- include dependencies
:gsub('%-%-.-\n','') -- remove disruptive line comments
:gsub('%-%-.-$','') -- remove unnecessary terminal comments
:gsub('<(%g%g-)>',function(r) return tostring(sqlvars[r]) end)
:gsub('%s+',' ') -- remove whitespace
:gsub('^%s*(.-)%s*$','%1') -- chomp
end
-- to simplify queries and reduce development headaches in general, we
-- offload as much logic as possible into views. to avoid versioning
-- difficulties, these views are not part of the schema, but are rather
|