mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-01 03:03:10 -06:00
Fix linter issues
This commit is contained in:
parent
d9f265b370
commit
92005c5090
|
|
@ -130,7 +130,7 @@ func (m *Migrator) ExecutedMigrations(ctx context.Context) (map[string]bool, err
|
|||
defer rows.Close() // nolint: errcheck
|
||||
var version string
|
||||
for rows.Next() {
|
||||
if err := rows.Scan(&version); err != nil {
|
||||
if err = rows.Scan(&version); err != nil {
|
||||
return nil, fmt.Errorf("unable to scan version: %w", err)
|
||||
}
|
||||
result[version] = true
|
||||
|
|
|
|||
|
|
@ -91,16 +91,16 @@ func Test_migrations_Up(t *testing.T) {
|
|||
t.Run(tt.name, func(t *testing.T) {
|
||||
db, err := sql.Open("sqlite3", tt.connectionString)
|
||||
if err != nil {
|
||||
t.Errorf("unable to open database: %w", err)
|
||||
t.Errorf("unable to open database: %v", err)
|
||||
}
|
||||
m := sqlutil.NewMigrator(db)
|
||||
m.AddMigrations(tt.migrations...)
|
||||
if err := m.Up(tt.ctx); (err != nil) != tt.wantErr {
|
||||
if err = m.Up(tt.ctx); (err != nil) != tt.wantErr {
|
||||
t.Errorf("Up() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
result, err := m.ExecutedMigrations(tt.ctx)
|
||||
if err != nil {
|
||||
t.Errorf("unable to get executed migrations: %w", err)
|
||||
t.Errorf("unable to get executed migrations: %v", err)
|
||||
}
|
||||
if !tt.wantErr && !reflect.DeepEqual(result, tt.wantResult) {
|
||||
t.Errorf("expected: %+v, got %v", tt.wantResult, result)
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ func NewPostgresKeyChangesTable(db *sql.DB) (tables.KeyChanges, error) {
|
|||
return s, err
|
||||
}
|
||||
|
||||
// TODO: Remove when we are sure we are not having goose artifacts in the db
|
||||
// TODO: Remove when we are sure we are not having goose artefacts in the db
|
||||
// This forces an error, which indicates the migration is already applied, since the
|
||||
// column partition was removed from the table
|
||||
var count int
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ func NewSqliteKeyChangesTable(db *sql.DB) (tables.KeyChanges, error) {
|
|||
if err != nil {
|
||||
return s, err
|
||||
}
|
||||
// TODO: Remove when we are sure we are not having goose artifacts in the db
|
||||
// TODO: Remove when we are sure we are not having goose artefacts in the db
|
||||
// This forces an error, which indicates the migration is already applied, since the
|
||||
// column partition was removed from the table
|
||||
var count int
|
||||
|
|
|
|||
|
|
@ -44,13 +44,13 @@ func Open(dbProperties *config.DatabaseOptions, cache caching.RoomServerCaches)
|
|||
}
|
||||
|
||||
// Create the tables.
|
||||
if err := d.create(db); err != nil {
|
||||
if err = d.create(db); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Special case, since this migration uses several tables, so it needs to
|
||||
// be sure that all tables are created first.
|
||||
// TODO: Remove when we are sure we are not having goose artifacts in the db
|
||||
// TODO: Remove when we are sure we are not having goose artefacts in the db
|
||||
// This forces an error, which indicates the migration is already applied, since the
|
||||
// column event_nid was removed from the table
|
||||
var count int
|
||||
|
|
|
|||
|
|
@ -52,13 +52,13 @@ func Open(dbProperties *config.DatabaseOptions, cache caching.RoomServerCaches)
|
|||
db.SetMaxOpenConns(20)
|
||||
|
||||
// Create the tables.
|
||||
if err := d.create(db); err != nil {
|
||||
if err = d.create(db); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Special case, since this migration uses several tables, so it needs to
|
||||
// be sure that all tables are created first.
|
||||
// TODO: Remove when we are sure we are not having goose artifacts in the db
|
||||
// TODO: Remove when we are sure we are not having goose artefacts in the db
|
||||
// This forces an error, which indicates the migration is already applied, since the
|
||||
// column event_nid was removed from the table
|
||||
var count int
|
||||
|
|
|
|||
|
|
@ -41,13 +41,13 @@ func NewDatabase(dbProperties *config.DatabaseOptions) (*SyncServerDatasource, e
|
|||
return nil, err
|
||||
}
|
||||
d.writer = sqlutil.NewExclusiveWriter()
|
||||
if err = d.prepare(dbProperties); err != nil {
|
||||
if err = d.prepare(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &d, nil
|
||||
}
|
||||
|
||||
func (d *SyncServerDatasource) prepare(dbProperties *config.DatabaseOptions) (err error) {
|
||||
func (d *SyncServerDatasource) prepare() (err error) {
|
||||
if err = d.streamID.prepare(d.db); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,10 @@ func NewSQLiteDevicesTable(db *sql.DB, serverName gomatrixserverlib.ServerName)
|
|||
Version: "add last_seen_ts",
|
||||
Up: deltas.UpLastSeenTSIP,
|
||||
})
|
||||
err = m.Up(context.Background())
|
||||
if err = m.Up(context.Background()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return s, sqlutil.StatementList{
|
||||
{&s.insertDeviceStmt, insertDeviceSQL},
|
||||
{&s.selectDevicesCountStmt, selectDevicesCountSQL},
|
||||
|
|
|
|||
Loading…
Reference in a new issue