sqlc: introduce NewForType helper method

The upcoming implementation of `sqldb/v2` will extensively create
a `Queries` object on the fly. To make more intuitive how to create
the queries object for specific database types, we introduce a
`NewForType` helper method.
This also mimics how `tapd` creates the `Queries` object, and in order
not let `litd` have it's own definition of how `Queries` object are
created on the fly, the upcoming `sqldb/v2` usage will utilize this
helper method.
This commit is contained in:
Viktor Torstensson 2025-07-24 13:18:55 +02:00
parent 91ed65954d
commit 2483339da9
No known key found for this signature in database
GPG key ID: 961CC8259AE675D4

View file

@ -36,6 +36,11 @@ func NewPostgres(db DBTX) *Queries {
return &Queries{db: &wrappedTX{db, sqldb.BackendTypePostgres}}
}
// NewForType creates a new Queries instance for the given database type.
func NewForType(db DBTX, typ sqldb.BackendType) *Queries {
return &Queries{db: &wrappedTX{db, typ}}
}
// CustomQueries defines a set of custom queries that we define in addition
// to the ones generated by sqlc.
type CustomQueries interface {