diff options
author | Kegan Dougal <kegan@matrix.org> | 2021-07-28 18:30:04 +0100 |
---|---|---|
committer | Kegan Dougal <kegan@matrix.org> | 2021-07-28 18:30:04 +0100 |
commit | ed4097825bc65f2332bcdc975ed201841221ff7c (patch) | |
tree | 4ac6270fa282b1d13ac73c97e4078f1961dbdf4e /userapi/storage/accounts/postgres/profile_table.go | |
parent | 9e4618000e0347741eac1279bf6c94c3b9980785 (diff) |
Factor out StatementList to `sqlutil` and use it in `userapi`
It helps with the boilerplate.
Diffstat (limited to 'userapi/storage/accounts/postgres/profile_table.go')
-rw-r--r-- | userapi/storage/accounts/postgres/profile_table.go | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/userapi/storage/accounts/postgres/profile_table.go b/userapi/storage/accounts/postgres/profile_table.go index 45d802f1..9313864b 100644 --- a/userapi/storage/accounts/postgres/profile_table.go +++ b/userapi/storage/accounts/postgres/profile_table.go @@ -64,22 +64,13 @@ func (s *profilesStatements) prepare(db *sql.DB) (err error) { if err != nil { return } - if s.insertProfileStmt, err = db.Prepare(insertProfileSQL); err != nil { - return - } - if s.selectProfileByLocalpartStmt, err = db.Prepare(selectProfileByLocalpartSQL); err != nil { - return - } - if s.setAvatarURLStmt, err = db.Prepare(setAvatarURLSQL); err != nil { - return - } - if s.setDisplayNameStmt, err = db.Prepare(setDisplayNameSQL); err != nil { - return - } - if s.selectProfilesBySearchStmt, err = db.Prepare(selectProfilesBySearchSQL); err != nil { - return - } - return + return sqlutil.StatementList{ + {&s.insertProfileStmt, insertProfileSQL}, + {&s.selectProfileByLocalpartStmt, selectProfileByLocalpartSQL}, + {&s.setAvatarURLStmt, setAvatarURLSQL}, + {&s.setDisplayNameStmt, setDisplayNameSQL}, + {&s.selectProfilesBySearchStmt, selectProfilesBySearchSQL}, + }.Prepare(db) } func (s *profilesStatements) insertProfile( |