Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
database/sql: allow drivers to support additional Value types #13567
It'd be useful if drivers could augment the list of data types supported by database/sql/convert.go. The ability to implement driver.Valuer and sql.Scanner for one's own structs is great, but there are core types I'd like to be able to use, as well. For example, PostgreSQL supports array types. I'd love to be able to convert between slices and SQL arrays. It makes sense that database/sql would not support this, but if there was an interface for the pg or pgx drivers to add it for core types, it would be super useful. Perhaps Driver could have methods for this kind of conversion? Maybe something like:
Then the drivers could be updated to, say, convert between
Databases can support non-standard result types. Common ones that are found include arrays, JSON, XML, table valued types, IP addresses, and GIS types.
For scanning custom result types I propose the following changes are made:
I think the above should allow returning any database supported type. Using any type as input parameters will be another issue.