lib / pq

Pure Go Postgres driver for database/sql
https://pkg.go.dev/github.com/lib/pq
MIT License
9.07k stars 911 forks source link

sequence key does not exist #760

Open rafa-acioly opened 6 years ago

rafa-acioly commented 6 years ago

I'm running a postgres container to create a database connection;

To be able to get the next value for a sequence i created a function like this;

create sequence seq_urls_id
func NextID() (id uint64, err error) {
    err = database.QueryRow("SELECT nextval('seq_urls_id')").Scan(&id)

    return
}

The error is;

pq: relation "seq_urls_id" does not exist

Inside my container if i run a simple select everything works fine;

SELECT nextval('seq_urls_id')

Output:

 nextvalue
------------
          2
(1 row)

I'm forgetting something? i've already search in documentation but found nothing

johto commented 6 years ago

I'm forgetting something? i've already search in documentation but found nothing

The driver doesn't do anything special here. You're either connected to the wrong database or the wrong cluster or you have a different search_path.