Further work on auto-generation of components

This commit is contained in:
Simon Brooke 2018-06-14 21:33:20 +01:00
parent 706e42f483
commit bfb5a67266
43 changed files with 2254 additions and 911 deletions

View file

@ -1,9 +1,11 @@
-- File queries.sql
-- autogenerated by adl.to-hugsql-queries at
-- 2018-06-11T20:39:10.396Z
-- See [Application Description Language](https://github.com/simon-brooke/adl).
------------------------------------------------------------------------
-- File queries.sql
--
-- autogenerated by adl.to-hugsql-queries at 2018-06-14T17:56:42.346Z
--
-- See [Application Description
-- Language](https://github.com/simon-brooke/adl).
------------------------------------------------------------------------
-- :name create-address! :! :n
-- :doc creates a new address record
@ -12,13 +14,15 @@ INSERT INTO addresses (address,
phone,
district_id,
latitude,
longitude)
longitude,
locality)
VALUES (:address,
:postcode,
:phone,
:district_id,
:latitude,
:longitude)
:longitude,
:locality)
returning id
-- :name create-authority! :! :n
@ -133,16 +137,6 @@ VALUES (:url,
:id)
returning id
-- :name create-issueexpertise! :! :n
-- :doc creates a new issueexpertise record
INSERT INTO issueexpertise (canvasser_id,
issue_id,
method_id)
VALUES (:canvasser_id,
:issue_id,
:method_id)
returning Id
-- :name create-option! :! :n
-- :doc creates a new option record
INSERT INTO options (id)
@ -155,14 +149,6 @@ INSERT INTO roles (name)
VALUES (:name)
returning id
-- :name create-rolemembership! :! :n
-- :doc creates a new rolemembership record
INSERT INTO rolememberships (role_id,
canvasser_id)
VALUES (:role_id,
:canvasser_id)
returning Id
-- :name create-team! :! :n
-- :doc creates a new team record
INSERT INTO teams (name,
@ -175,22 +161,6 @@ VALUES (:name,
:longitude)
returning id
-- :name create-teammembership! :! :n
-- :doc creates a new teammembership record
INSERT INTO teammemberships (team_id,
canvasser_id)
VALUES (:team_id,
:canvasser_id)
returning Id
-- :name create-teamorganisership! :! :n
-- :doc creates a new teamorganisership record
INSERT INTO teamorganiserships (team_id,
canvasser_id)
VALUES (:team_id,
:canvasser_id)
returning Id
-- :name create-visit! :! :n
-- :doc creates a new visit record
INSERT INTO visits (address_id,
@ -261,11 +231,6 @@ WHERE intentions.Id = :Id
DELETE FROM issues
WHERE issues.id = :id
-- :name delete-issueexpertise! :! :n
-- :doc updates an existing issueexpertise record
DELETE FROM issueexpertise
WHERE issueexpertise.Id = :Id
-- :name delete-option! :! :n
-- :doc updates an existing option record
DELETE FROM options
@ -276,26 +241,11 @@ WHERE options.id = :id
DELETE FROM roles
WHERE roles.id = :id
-- :name delete-rolemembership! :! :n
-- :doc updates an existing rolemembership record
DELETE FROM rolememberships
WHERE rolememberships.Id = :Id
-- :name delete-team! :! :n
-- :doc updates an existing team record
DELETE FROM teams
WHERE teams.id = :id
-- :name delete-teammembership! :! :n
-- :doc updates an existing teammembership record
DELETE FROM teammemberships
WHERE teammemberships.Id = :Id
-- :name delete-teamorganisership! :! :n
-- :doc updates an existing teamorganisership record
DELETE FROM teamorganiserships
WHERE teamorganiserships.Id = :Id
-- :name delete-visit! :! :n
-- :doc updates an existing visit record
DELETE FROM visits
@ -343,6 +293,9 @@ ORDER BY districts.name,
-- :doc selects an existing dwelling record
SELECT * FROM dwellings
WHERE dwellings.id = :id
ORDER BY dwellings.address_id,
dwellings.sub-address,
dwellings.id
-- :name get-elector :? :1
-- :doc selects an existing elector record
@ -351,12 +304,16 @@ WHERE electors.id = :id
ORDER BY electors.name,
electors.phone,
electors.email,
electors.gender,
electors.id
-- :name get-followupaction :? :1
-- :doc selects an existing followupaction record
SELECT * FROM followupactions
WHERE followupactions.id = :id
ORDER BY followupactions.date,
followupactions.notes,
followupactions.id
-- :name get-followupmethod :? :1
-- :doc selects an existing followupmethod record
@ -367,6 +324,10 @@ WHERE followupmethods.id = :id
-- :doc selects an existing followuprequest record
SELECT * FROM followuprequests
WHERE followuprequests.id = :id
ORDER BY followuprequests.elector_id,
followuprequests.visit_id,
followuprequests.issue_id,
followuprequests.id
-- :name get-gender :? :1
-- :doc selects an existing gender record
@ -383,11 +344,6 @@ WHERE intentions.Id = :Id
SELECT * FROM issues
WHERE issues.id = :id
-- :name get-issueexpertise :? :1
-- :doc selects an existing issueexpertise record
SELECT * FROM issueexpertise
WHERE issueexpertise.Id = :Id
-- :name get-option :? :1
-- :doc selects an existing option record
SELECT * FROM options
@ -400,10 +356,12 @@ WHERE roles.id = :id
ORDER BY roles.name,
roles.id
-- :name get-rolemembership :? :1
-- :doc selects an existing rolemembership record
SELECT * FROM rolememberships
WHERE rolememberships.Id = :Id
-- :name get-role-by-name :? :1
-- :doc selects an existing role record
SELECT * FROM roles
WHERE roles.name = :name
ORDER BY roles.name,
roles.id
-- :name get-team :? :1
-- :doc selects an existing team record
@ -412,20 +370,13 @@ WHERE teams.id = :id
ORDER BY teams.name,
teams.id
-- :name get-teammembership :? :1
-- :doc selects an existing teammembership record
SELECT * FROM teammemberships
WHERE teammemberships.Id = :Id
-- :name get-teamorganisership :? :1
-- :doc selects an existing teamorganisership record
SELECT * FROM teamorganiserships
WHERE teamorganiserships.Id = :Id
-- :name get-visit :? :1
-- :doc selects an existing visit record
SELECT * FROM visits
WHERE visits.id = :id
ORDER BY visits.address_id,
visits.date,
visits.id
-- :name list-addresses :? :*
-- :doc lists all existing address records
@ -494,9 +445,9 @@ ORDER BY canvassers.username,
-- :name list-canvassers-by-role :? :*
-- :doc links all existing canvasser records related to a given role
SELECT *
FROM canvassers, link_canvassers_
WHERE canvassers.id = link_canvassers_.canvasser_id
AND link_canvassers_.role_id = :id
FROM canvassers, ln_canvassers_roles
WHERE canvassers.id = ln_canvassers_roles.canvasser_id
AND ln_canvassers_roles.role_id = :id
ORDER BY canvassers.username,
canvassers.fullname,
canvassers.email,
@ -513,6 +464,9 @@ ORDER BY districts.name,
-- :name list-dwellings :? :*
-- :doc lists all existing dwelling records
SELECT * FROM dwellings
ORDER BY dwellings.address_id,
dwellings.sub-address,
dwellings.id
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
@ -521,6 +475,9 @@ SELECT * FROM dwellings
SELECT *
FROM dwellings
WHERE dwellings.address_id = :id
ORDER BY dwellings.address_id,
dwellings.sub-address,
dwellings.id
-- :name list-electors :? :*
-- :doc lists all existing elector records
@ -528,6 +485,7 @@ SELECT * FROM electors
ORDER BY electors.name,
electors.phone,
electors.email,
electors.gender,
electors.id
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
@ -540,6 +498,7 @@ WHERE electors.dwelling_id = :id
ORDER BY electors.name,
electors.phone,
electors.email,
electors.gender,
electors.id
-- :name list-electors-by-gender :? :*
@ -550,11 +509,15 @@ WHERE electors.gender = :id
ORDER BY electors.name,
electors.phone,
electors.email,
electors.gender,
electors.id
-- :name list-followupactions :? :*
-- :doc lists all existing followupaction records
SELECT * FROM followupactions
ORDER BY followupactions.date,
followupactions.notes,
followupactions.id
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
@ -563,12 +526,18 @@ SELECT * FROM followupactions
SELECT *
FROM followupactions
WHERE followupactions.actor = :id
ORDER BY followupactions.date,
followupactions.notes,
followupactions.id
-- :name list-followupactions-by-followuprequest :? :*
-- :doc lists all existing followupaction records related to a given followuprequest
SELECT *
FROM followupactions
WHERE followupactions.request_id = :id
ORDER BY followupactions.date,
followupactions.notes,
followupactions.id
-- :name list-followupmethods :? :*
-- :doc lists all existing followupmethod records
@ -579,6 +548,10 @@ SELECT * FROM followupmethods
-- :name list-followuprequests :? :*
-- :doc lists all existing followuprequest records
SELECT * FROM followuprequests
ORDER BY followuprequests.elector_id,
followuprequests.visit_id,
followuprequests.issue_id,
followuprequests.id
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
@ -587,24 +560,40 @@ SELECT * FROM followuprequests
SELECT *
FROM followuprequests
WHERE followuprequests.elector_id = :id
ORDER BY followuprequests.elector_id,
followuprequests.visit_id,
followuprequests.issue_id,
followuprequests.id
-- :name list-followuprequests-by-followupmethod :? :*
-- :doc lists all existing followuprequest records related to a given followupmethod
SELECT *
FROM followuprequests
WHERE followuprequests.method_id = :id
ORDER BY followuprequests.elector_id,
followuprequests.visit_id,
followuprequests.issue_id,
followuprequests.id
-- :name list-followuprequests-by-issue :? :*
-- :doc lists all existing followuprequest records related to a given issue
SELECT *
FROM followuprequests
WHERE followuprequests.issue_id = :id
ORDER BY followuprequests.elector_id,
followuprequests.visit_id,
followuprequests.issue_id,
followuprequests.id
-- :name list-followuprequests-by-visit :? :*
-- :doc lists all existing followuprequest records related to a given visit
SELECT *
FROM followuprequests
WHERE followuprequests.visit_id = :id
ORDER BY followuprequests.elector_id,
followuprequests.visit_id,
followuprequests.issue_id,
followuprequests.id
-- :name list-genders :? :*
-- :doc lists all existing gender records
@ -636,30 +625,6 @@ SELECT *
FROM intentions
WHERE intentions.visit_id = :id
-- :name list-issueexpertise :? :*
-- :doc lists all existing issueexpertise records
SELECT * FROM issueexpertise
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
-- :name list-issueexpertise-by-canvasser :? :*
-- :doc lists all existing issueexpertise records related to a given canvasser
SELECT *
FROM issueexpertise
WHERE issueexpertise.canvasser_id = :id
-- :name list-issueexpertise-by-followupmethod :? :*
-- :doc lists all existing issueexpertise records related to a given followupmethod
SELECT *
FROM issueexpertise
WHERE issueexpertise.method_id = :id
-- :name list-issueexpertise-by-issue :? :*
-- :doc lists all existing issueexpertise records related to a given issue
SELECT *
FROM issueexpertise
WHERE issueexpertise.issue_id = :id
-- :name list-issues :? :*
-- :doc lists all existing issue records
SELECT * FROM issues
@ -672,24 +637,6 @@ SELECT * FROM options
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
-- :name list-rolememberships :? :*
-- :doc lists all existing rolemembership records
SELECT * FROM rolememberships
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
-- :name list-rolememberships-by-canvasser :? :*
-- :doc lists all existing rolemembership records related to a given canvasser
SELECT *
FROM rolememberships
WHERE rolememberships.canvasser_id = :id
-- :name list-rolememberships-by-role :? :*
-- :doc lists all existing rolemembership records related to a given role
SELECT *
FROM rolememberships
WHERE rolememberships.role_id = :id
-- :name list-roles :? :*
-- :doc lists all existing role records
SELECT * FROM roles
@ -701,48 +648,12 @@ ORDER BY roles.name,
-- :name list-roles-by-canvasser :? :*
-- :doc links all existing role records related to a given canvasser
SELECT *
FROM roles, link_roles_canvassers
WHERE roles.id = link_roles_canvassers.role_id
AND link_roles_canvassers.canvasser_id = :id
FROM roles, ln_canvassers_roles
WHERE roles.id = ln_canvassers_roles.role_id
AND ln_canvassers_roles.canvasser_id = :id
ORDER BY roles.name,
roles.id
-- :name list-teammemberships :? :*
-- :doc lists all existing teammembership records
SELECT * FROM teammemberships
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
-- :name list-teammemberships-by-canvasser :? :*
-- :doc lists all existing teammembership records related to a given canvasser
SELECT *
FROM teammemberships
WHERE teammemberships.canvasser_id = :id
-- :name list-teammemberships-by-team :? :*
-- :doc lists all existing teammembership records related to a given team
SELECT *
FROM teammemberships
WHERE teammemberships.team_id = :id
-- :name list-teamorganiserships :? :*
-- :doc lists all existing teamorganisership records
SELECT * FROM teamorganiserships
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
-- :name list-teamorganiserships-by-canvasser :? :*
-- :doc lists all existing teamorganisership records related to a given canvasser
SELECT *
FROM teamorganiserships
WHERE teamorganiserships.canvasser_id = :id
-- :name list-teamorganiserships-by-team :? :*
-- :doc lists all existing teamorganisership records related to a given team
SELECT *
FROM teamorganiserships
WHERE teamorganiserships.team_id = :id
-- :name list-teams :? :*
-- :doc lists all existing team records
SELECT * FROM teams
@ -754,9 +665,9 @@ ORDER BY teams.name,
-- :name list-teams-by-canvasser :? :*
-- :doc links all existing team records related to a given canvasser
SELECT *
FROM teams, link_teams_canvassers
WHERE teams.id = link_teams_canvassers.team_id
AND link_teams_canvassers.canvasser_id = :id
FROM teams, ln_canvassers_teams
WHERE teams.id = ln_canvassers_teams.team_id
AND ln_canvassers_teams.canvasser_id = :id
ORDER BY teams.name,
teams.id
@ -771,6 +682,9 @@ ORDER BY teams.name,
-- :name list-visits :? :*
-- :doc lists all existing visit records
SELECT * FROM visits
ORDER BY visits.address_id,
visits.date,
visits.id
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
@ -779,12 +693,18 @@ SELECT * FROM visits
SELECT *
FROM visits
WHERE visits.address_id = :id
ORDER BY visits.address_id,
visits.date,
visits.id
-- :name list-visits-by-canvasser :? :*
-- :doc lists all existing visit records related to a given canvasser
SELECT *
FROM visits
WHERE visits.canvasser_id = :id
ORDER BY visits.address_id,
visits.date,
visits.id
-- :name search-strings-address :? :1
-- :doc selects existing address records having any string field matching `:pattern` by substring match
@ -836,6 +756,9 @@ ORDER BY districts.name,
SELECT * FROM dwellings
WHERE
sub-address LIKE '%:pattern%'
ORDER BY dwellings.address_id,
dwellings.sub-address,
dwellings.id
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
@ -849,6 +772,7 @@ name LIKE '%:pattern%'
ORDER BY electors.name,
electors.phone,
electors.email,
electors.gender,
electors.id
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
@ -858,6 +782,9 @@ ORDER BY electors.name,
SELECT * FROM followupactions
WHERE
notes LIKE '%:pattern%'
ORDER BY followupactions.date,
followupactions.notes,
followupactions.id
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
@ -873,6 +800,10 @@ id LIKE '%:pattern%'
-- :doc selects existing followuprequest records having any string field matching `:pattern` by substring match
SELECT * FROM followuprequests
WHERE
ORDER BY followuprequests.elector_id,
followuprequests.visit_id,
followuprequests.issue_id,
followuprequests.id
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
@ -900,13 +831,6 @@ url LIKE '%:pattern%'
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
-- :name search-strings-issueexpertise :? :1
-- :doc selects existing issueexpertise records having any string field matching `:pattern` by substring match
SELECT * FROM issueexpertise
WHERE
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
-- :name search-strings-option :? :1
-- :doc selects existing option records having any string field matching `:pattern` by substring match
SELECT * FROM options
@ -925,13 +849,6 @@ ORDER BY roles.name,
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
-- :name search-strings-rolemembership :? :1
-- :doc selects existing rolemembership records having any string field matching `:pattern` by substring match
SELECT * FROM rolememberships
WHERE
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
-- :name search-strings-team :? :1
-- :doc selects existing team records having any string field matching `:pattern` by substring match
SELECT * FROM teams
@ -942,24 +859,13 @@ ORDER BY teams.name,
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
-- :name search-strings-teammembership :? :1
-- :doc selects existing teammembership records having any string field matching `:pattern` by substring match
SELECT * FROM teammemberships
WHERE
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
-- :name search-strings-teamorganisership :? :1
-- :doc selects existing teamorganisership records having any string field matching `:pattern` by substring match
SELECT * FROM teamorganiserships
WHERE
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
-- :name search-strings-visit :? :1
-- :doc selects existing visit records having any string field matching `:pattern` by substring match
SELECT * FROM visits
WHERE
ORDER BY visits.address_id,
visits.date,
visits.id
--~ (if (:offset params) "OFFSET :offset ")
--~ (if (:limit params) "LIMIT :limit" "LIMIT 100")
@ -971,7 +877,8 @@ SET address = :address,
phone = :phone,
district_id = :district_id,
latitude = :latitude,
longitude = :longitude
longitude = :longitude,
locality = :locality
WHERE addresses.id = :id
-- :name update-canvasser! :! :n
@ -1045,27 +952,12 @@ SET url = :url,
id = :id
WHERE issues.id = :id
-- :name update-issueexpertise! :! :n
-- :doc updates an existing issueexpertise record
UPDATE issueexpertise
SET canvasser_id = :canvasser_id,
issue_id = :issue_id,
method_id = :method_id
WHERE issueexpertise.Id = :Id
-- :name update-role! :! :n
-- :doc updates an existing role record
UPDATE roles
SET name = :name
WHERE roles.id = :id
-- :name update-rolemembership! :! :n
-- :doc updates an existing rolemembership record
UPDATE rolememberships
SET role_id = :role_id,
canvasser_id = :canvasser_id
WHERE rolememberships.Id = :Id
-- :name update-team! :! :n
-- :doc updates an existing team record
UPDATE teams
@ -1075,20 +967,6 @@ SET name = :name,
longitude = :longitude
WHERE teams.id = :id
-- :name update-teammembership! :! :n
-- :doc updates an existing teammembership record
UPDATE teammemberships
SET team_id = :team_id,
canvasser_id = :canvasser_id
WHERE teammemberships.Id = :Id
-- :name update-teamorganisership! :! :n
-- :doc updates an existing teamorganisership record
UPDATE teamorganiserships
SET team_id = :team_id,
canvasser_id = :canvasser_id
WHERE teamorganiserships.Id = :Id
-- :name update-visit! :! :n
-- :doc updates an existing visit record
UPDATE visits