You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I'm experiencing a problem with the package where because of the custom Valuer interface, the types that do implement driver.Valuer are not recognized.
For context, I'm using github.com/google/uuid type and since it does implement driver.Valuer interface I expected it to automatically convert to string, so doing something like this would just work:
funcmyFunc(ctx context.Context, id uuid.UUID) error {
q:=pgq.Update("table").Where(pgq.Eq{"id": id})
}
Is there a reason to not use driver.Valuer interface? It's semantically the same since driver.Valuer is Value() (driver.Value, error) where driver.Value is just an alias to any.
The text was updated successfully, but these errors were encountered:
Could you please help me understand what is happening?
What is your Go version?
What is your pgq version?
What is your google/uuid version?
Using Go 1.20, pgq v0.0.2, and github.com/google/uuid v1.3.0, I tested the following code and it worked for me:
q:=pgq.Update("table").Where(pgq.Eq{"id": uuid.New()}).Set("x", "y")
fmt.Println(q.SQL())
// Example of output:// UPDATE table SET x = $1 WHERE id = ANY ($2) [y 59de013e-0348-4c19-9b10-9ada2a673575] <nil>
But answering you: the reason I avoided database/sql and database/sql/driver is that this query builder generates queries that aren't compatible with it as I want to take advantage of being able to produce queries that take advantage of PostgreSQL's native protocol as much as possible, including passing slices as an argument.
Hi! I'm experiencing a problem with the package where because of the custom
Valuer
interface, the types that do implementdriver.Valuer
are not recognized.For context, I'm using
github.com/google/uuid
type and since it does implementdriver.Valuer
interface I expected it to automatically convert to string, so doing something like this would just work:Is there a reason to not use
driver.Valuer
interface? It's semantically the same sincedriver.Valuer
isValue() (driver.Value, error)
wheredriver.Value
is just an alias toany
.The text was updated successfully, but these errors were encountered: