Skip to content

support opening a connection with custom flags#126

Open
oxtoacart wants to merge 1 commit intomainfrom
percy/corp36592
Open

support opening a connection with custom flags#126
oxtoacart wants to merge 1 commit intomainfrom
percy/corp36592

Conversation

@oxtoacart
Copy link
Contributor

The new ConnectFlags supports passing in sqliteh.OpenFlags to configure the connection.

Connect still uses sqliteh.OpenFlagsDefault.

Updates tailscale/corp#36592

@oxtoacart oxtoacart requested review from knyar and zofrex and removed request for zofrex February 3, 2026 16:13
sqlite.go Outdated
// Connect implements [driver.Connector.Connect]
func (p *connector) Connect(ctx context.Context) (driver.Conn, error) {
db, err := Open(p.name, sqliteh.OpenFlagsDefault, "")
return p.ConnectFlags(ctx, sqliteh.OpenFlagsDefault)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to use the passed flags here instead of the default?

Suggested change
return p.ConnectFlags(ctx, sqliteh.OpenFlagsDefault)
return p.ConnectFlags(ctx, p.openFlags)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed!

This introduces the use of the options pattern with the new `ConnectorWithOpts`
function. The opt `WithOpenFlags` allows specifying custom flags to use when
opening connections. When left unspecified, we use the same
`sqliteh.OpenFlagsDefault` as before.

Updates tailscale/corp#36592

Signed-off-by: Percy Wegmann <percy@tailscale.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants