gotro
gotro copied to clipboard
Error when creating a postgresql table
There is an error when running the CreateBaseTable function in the postgreSQL package (D/Pg), where the table is created successfully but the index fails, because the DDL process did not return the affected rows.
The following is the code that is executed:
package main
import (
"github.com/kokizzu/gotro/D/Pg"
)
func main() {
pg_conn := Pg.NewConn(`db`, `pass`)
pg_conn.CreateBaseTable(`users`, `users`)
}
there is an error here
ra, _ := tx.DoExec(query).RowsAffected()
if ra > 0 {
// will never get in here
}
maybe it should be like this
_, err := tx.DoExec(query).RowsAffected()
if err == nil {
// create index
}
Terima kasih Pak @kokizzu :)