Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pg: Model(unsupported *int32) #1849

Closed
ivoras opened this issue Mar 20, 2021 · 3 comments
Closed

pg: Model(unsupported *int32) #1849

ivoras opened this issue Mar 20, 2021 · 3 comments

Comments

@ivoras
Copy link

ivoras commented Mar 20, 2021

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.

@ivoras
Copy link
Author

ivoras commented Mar 20, 2021

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

@ivoras ivoras closed this as completed Mar 20, 2021
@fedemengo
Copy link

fedemengo commented Feb 15, 2023

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

@ivoras
Copy link
Author

ivoras commented Feb 15, 2023

yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants