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

inconsistent return value from pg_stat_database datname column. #480

Closed
james-lawrence opened this issue Aug 9, 2016 · 3 comments
Closed

Comments

@james-lawrence
Copy link

james-lawrence commented Aug 9, 2016

func main() {
    // using string returns a string as expected.
    // var datname string
    // using interface{} returns a []byte
    var datname interface{}

    // db, err := sql.Open("postgres", "postgres://user:password@host:5432/database?sslmode=disable")
    if err != nil {
        log.Fatalln(err)
    }
    row := db.QueryRow("SELECT datname::text FROM pg_stat_database LIMIT 1")
    err = row.Scan(&datname)

    log.Println("datname", datname, err)
}

returns a []byte when an interface{} is provided, correctly returns a string when a string is provided. It should be consistently a string.

@cbandy
Copy link
Contributor

cbandy commented Aug 22, 2016

Are you using a recent version of this package? I believe text type has been returned as string since #436.

@freeformz
Copy link

This works fine for me with master.

@james-lawrence
Copy link
Author

james-lawrence commented Aug 23, 2016

i was likely on an old version at a time. closing works for me with latest as well. my bad.

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

3 participants