fix: sqlite and postgres, close rows and pass nothing instead nil
This commit is contained in:
parent
1701db7b8e
commit
a2e66ce08b
@ -401,7 +401,7 @@ func (postgres *Postgres) SelectHumidities(ctx context.Context) ([]*types.Measur
|
||||
return nil, err
|
||||
}
|
||||
|
||||
measuredValues, err := postgres.selectMeasuredValue(tx, query, nil)
|
||||
measuredValues, err := postgres.selectMeasuredValue(tx, query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -502,7 +502,7 @@ func (postgres *Postgres) SelectPressures(ctx context.Context) ([]*types.Measure
|
||||
return nil, err
|
||||
}
|
||||
|
||||
measuredValues, err := postgres.selectMeasuredValue(tx, query, nil)
|
||||
measuredValues, err := postgres.selectMeasuredValue(tx, query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -662,7 +662,7 @@ func (postgres *Postgres) SelectTemperatures(ctx context.Context) ([]*types.Meas
|
||||
return nil, err
|
||||
}
|
||||
|
||||
measuredValues, err := postgres.selectMeasuredValue(tx, query, nil)
|
||||
measuredValues, err := postgres.selectMeasuredValue(tx, query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -312,6 +312,7 @@ func (sqlite *SQLite) selectDevices(tx *sql.Tx, query string, args ...interface{
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to query statement: %v", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
devices := make([]*types.Device, 0)
|
||||
for rows.Next() {
|
||||
@ -379,7 +380,7 @@ func (sqlite *SQLite) SelectHumidities(ctx context.Context) ([]*types.MeasuredVa
|
||||
return nil, err
|
||||
}
|
||||
|
||||
measuredValues, err := sqlite.selectMeasuredValue(tx, query, nil)
|
||||
measuredValues, err := sqlite.selectMeasuredValue(tx, query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -409,6 +410,7 @@ func (sqlite *SQLite) selectMeasuredValue(tx *sql.Tx, query string, args ...inte
|
||||
tx.Rollback()
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
measuredValues := make([]*types.MeasuredValue, 0)
|
||||
for rows.Next() {
|
||||
@ -416,8 +418,8 @@ func (sqlite *SQLite) selectMeasuredValue(tx *sql.Tx, query string, args ...inte
|
||||
err := rows.Scan(
|
||||
&measuredValue.ID,
|
||||
&measuredValue.Value,
|
||||
&measuredValue.SensorID,
|
||||
&measuredValue.Date,
|
||||
&measuredValue.SensorID,
|
||||
&measuredValue.CreationDate,
|
||||
&measuredValue.UpdateDate,
|
||||
)
|
||||
@ -480,7 +482,7 @@ func (sqlite *SQLite) SelectPressures(ctx context.Context) ([]*types.MeasuredVal
|
||||
return nil, err
|
||||
}
|
||||
|
||||
measuredValues, err := sqlite.selectMeasuredValue(tx, query, nil)
|
||||
measuredValues, err := sqlite.selectMeasuredValue(tx, query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -564,6 +566,7 @@ func (sqlite *SQLite) selectSensors(tx *sql.Tx, query string, args ...interface{
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to query statement: %v", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
sensors := make([]*types.Sensor, 0)
|
||||
for rows.Next() {
|
||||
@ -640,7 +643,7 @@ func (sqlite *SQLite) SelectTemperatures(ctx context.Context) ([]*types.Measured
|
||||
return nil, err
|
||||
}
|
||||
|
||||
measuredValues, err := sqlite.selectMeasuredValue(tx, query, nil)
|
||||
measuredValues, err := sqlite.selectMeasuredValue(tx, query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user