all repos — honk @ 34a510a500ca03130f56afa54556e2b5eebf0a9c

my fork of honk

fill in null columns with empty strings
Ted Unangst tedu@tedunangst.com
Wed, 02 Sep 2020 16:31:02 -0400
commit

34a510a500ca03130f56afa54556e2b5eebf0a9c

parent

403bc4439ff4702e803f2c171982044e552014a5

2 files changed, 15 insertions(+), 4 deletions(-)

jump to
M database.godatabase.go

@@ -880,7 +880,7 @@ }

func prepareStatements(db *sql.DB) { stmtHonkers = preparetodie(db, "select honkerid, userid, name, xid, flavor, combos, meta from honkers where userid = ? and (flavor = 'presub' or flavor = 'sub' or flavor = 'peep' or flavor = 'unsub') order by name") - stmtSaveHonker = preparetodie(db, "insert into honkers (userid, name, xid, flavor, combos, owner, meta) values (?, ?, ?, ?, ?, ?, ?)") + stmtSaveHonker = preparetodie(db, "insert into honkers (userid, name, xid, flavor, combos, owner, meta, folxid) values (?, ?, ?, ?, ?, ?, ?, '')") stmtUpdateFlavor = preparetodie(db, "update honkers set flavor = ? where userid = ? and xid = ? and name = ? and flavor = ?") stmtUpdateHonker = preparetodie(db, "update honkers set name = ?, combos = ?, meta = ? where honkerid = ? and userid = ?") stmtOneHonker = preparetodie(db, "select xid from honkers where name = ? and userid = ?")

@@ -927,7 +927,7 @@ stmtFindXonk = preparetodie(db, "select honkid from honks where userid = ? and xid = ?")

stmtFindFile = preparetodie(db, "select fileid, xid from filemeta where url = ? and local = 1") stmtUserByName = preparetodie(db, "select userid, username, displayname, about, pubkey, seckey, options from users where username = ? and userid > 0") stmtUserByNumber = preparetodie(db, "select userid, username, displayname, about, pubkey, seckey, options from users where userid = ?") - stmtSaveDub = preparetodie(db, "insert into honkers (userid, name, xid, flavor) values (?, ?, ?, ?)") + stmtSaveDub = preparetodie(db, "insert into honkers (userid, name, xid, flavor, combos, owner, meta, folxid) values (?, ?, ?, ?, '', '', '', '')") stmtAddDoover = preparetodie(db, "insert into doovers (dt, tries, userid, rcpt, msg) values (?, ?, ?, ?, ?)") stmtGetDoovers = preparetodie(db, "select dooverid, dt from doovers") stmtLoadDoover = preparetodie(db, "select tries, userid, rcpt, msg from doovers where dooverid = ?")
M upgradedb.goupgradedb.go

@@ -23,9 +23,13 @@ "strings"

"time" ) -var myVersion = 37 +var myVersion = 38 -func doordie(db *sql.DB, s string, args ...interface{}) { +type dbexecer interface { + Exec(query string, args ...interface{}) (sql.Result, error) +} + +func doordie(db dbexecer, s string, args ...interface{}) { _, err := db.Exec(s, args...) if err != nil { log.Fatalf("can't run %s: %s", s, err)

@@ -153,6 +157,13 @@ doordie(db, "update honkers set folxid = 'lostdata'")

doordie(db, "update config set value = 37 where key = 'dbversion'") fallthrough case 37: + doordie(db, "update honkers set combos = '' where combos is null") + doordie(db, "update honkers set owner = '' where owner is null") + doordie(db, "update honkers set meta = '' where meta is null") + doordie(db, "update honkers set folxid = '' where folxid is null") + doordie(db, "update config set value = 38 where key = 'dbversion'") + fallthrough + case 38: default: log.Fatalf("can't upgrade unknown version %d", dbversion)