~emersion/soju

cc83da4cd1e9ffae1cd679c3edeb8c5b922855e0 — Alexey Yerin 19 days ago 9b40cfe
db: match placeholders with columns

Soju inserts 9 columns but only with 8 placeholders. This causes
channels not being saved properly and also logging errors like this:

    downstream ...: failed to create or update channel ...: 8 values for 9 columns
1 files changed, 1 insertions(+), 1 deletions(-)

M db.go
M db.go => db.go +1 -1
@@ 596,7 596,7 @@ func (db *DB) StoreChannel(networkID int64, ch *Channel) error {
	} else {
		var res sql.Result
		res, err = db.db.Exec(`INSERT INTO Channel(network, name, key, detached, detached_internal_msgid, relay_detached, reattach_on, detach_after, detach_on)
			VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
			VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
			networkID, ch.Name, key, ch.Detached, toNullString(ch.DetachedInternalMsgID), ch.RelayDetached, ch.ReattachOn, detachAfter, ch.DetachOn)
		if err != nil {
			return err