go-pg/pg

pg: Model(unsupported *int32)

ivoras opened this issue · 3 comments

I've upgraded from v8 to v10, and code suddenly stopped working. There's a function which does this:

func (db *EquinoxDb) IncSectorVersion(geohash uint64) (v int32, err error) {
        _, err = db.QueryOne(&v, "UPDATE sector SET version=version+1 WHERE geohash=? RETURNING version", geohash)
        if err == pg.ErrNoRows {
                _, err = db.QueryOne(&v, `INSERT INTO sector(geohash) VALUES(?) RETURNING version`, geohash)
        }
        return
}

This has worked before, but now errors out with pg: Model(unsupported *int32).

Expected Behavior

Queries return data in the provided *int32 value.

Current Behavior

pg: Model(unsupported *int32)

Possible Solution

Is support for the int32 data type removed?

My go.mod says this is on go-pg v10.7.7.

Apparently I missed that i need pg.Scan(&v) to get scalar values.

@ivoras what was the fix? db.QueryOne(pg.Scan(&v), ....)?

yes