Simplify preparing the roomserver SQL (#172)

This commit is contained in:
Mark Haines 2017-08-02 16:50:34 +01:00 committed by GitHub
parent 0fbb8b7824
commit 3b07633326

View File

@ -33,40 +33,20 @@ type statements struct {
func (s *statements) prepare(db *sql.DB) error { func (s *statements) prepare(db *sql.DB) error {
var err error var err error
if err = s.eventTypeStatements.prepare(db); err != nil { for _, prepare := range []func(db *sql.DB) error{
return err s.eventTypeStatements.prepare,
} s.eventStateKeyStatements.prepare,
s.roomStatements.prepare,
if err = s.eventStateKeyStatements.prepare(db); err != nil { s.eventStatements.prepare,
return err s.eventJSONStatements.prepare,
} s.stateSnapshotStatements.prepare,
s.stateBlockStatements.prepare,
if err = s.roomStatements.prepare(db); err != nil { s.previousEventStatements.prepare,
return err s.roomAliasesStatements.prepare,
} } {
if err = prepare(db); err != nil {
if err = s.eventStatements.prepare(db); err != nil { return err
return err }
}
if err = s.eventJSONStatements.prepare(db); err != nil {
return err
}
if err = s.stateSnapshotStatements.prepare(db); err != nil {
return err
}
if err = s.stateBlockStatements.prepare(db); err != nil {
return err
}
if err = s.previousEventStatements.prepare(db); err != nil {
return err
}
if err = s.roomAliasesStatements.prepare(db); err != nil {
return err
} }
return nil return nil