Open kevinburkeshyp opened 8 years ago
Reading through the tests, it seems like I can only do this if I pass binary_parameters=yes as part of the connection string. However, the consequences of doing so are not very clear; it seems like this goes down a branch that disables prepared statements?
No, it doesn't do that. It just uses the underlying protocol a bit differently.
But yeah, with that option byte slices are passed to the database as-is in binary, which means that passing a UUID as a 16-byte slice works directly.
It would be nice if there was more documentation/help around how to pass UUID's to the database; I'm just using a string for now.
Yup, that's how you do it. Every type not recognized by database/sql has to be passed as the text representation of the type, except for bytea values which are converted in the driver automatically for historical reasons. We can't possibly be expected to list how to pass every single type in the documentation, but we could probably do a bit better.
Here's some relevant PostgreSQL documentation: http://www.postgresql.org/docs/current/static/protocol-overview.html#PROTOCOL-FORMAT-CODES
The binary format of nontrivial types is ... deep knowledge.
I'm trying to send/read UUID's from the database. My first thought was that UUID's were 16 bytes, so I should be able to send
[]byte
to the database, but this failed with the22021
error.Reading through the tests, it seems like I can only do this if I pass
binary_parameters=yes
as part of the connection string. However, the consequences of doing so are not very clear; it seems like this goes down a branch that disables prepared statements?It would be nice if there was more documentation/help around how to pass UUID's to the database; I'm just using a string for now.