canonical / sqlair

Friendly type mapping for SQL databases
Apache License 2.0
17 stars 8 forks source link

Add ergonomic methods #63

Closed Aflynn50 closed 8 months ago

Aflynn50 commented 1 year ago

This PR adds a method, With, to the database. It also changes Query to accept strings as well as prepared statements. If a query has no output expressions then it can be prepared only using the input arguments, if there are output expressions type samples can be passed to With.

The type samples are stored indefinitely alongside the database in the typeSamples slice.

Note that ideally we would use Generics here for the type of the Statement/string instead of any in DB.Query but Go does not allow generics in methods on structs.