If there's no updates, don't insert anything

This commit is contained in:
Kegan Dougal 2024-05-17 15:37:45 +01:00
parent fcd9b490f9
commit 5028f93f83

View File

@ -122,6 +122,9 @@ func upDeviceListTable(ctx context.Context, tx *sql.Tx) error {
Bucket: state.BucketSent,
})
}
if len(deviceListRows) == 0 {
continue
}
chunks := sqlutil.Chunkify(5, state.MaxPostgresParameters, state.DeviceListChunker(deviceListRows))
for _, chunk := range chunks {
var placeholders []string
@ -143,8 +146,6 @@ func upDeviceListTable(ctx context.Context, tx *sql.Tx) error {
)
_, err = tx.ExecContext(ctx, query, vals...)
if err != nil {
fmt.Println(query)
fmt.Println(vals...)
return fmt.Errorf("failed to bulk insert: %s", err)
}
}