Skip to content

feat: OpenDB api now sets few configs passed via options#1675

Merged
kavirajk merged 1 commit intomainfrom
kavirajk/opendb-api-settings-fix
Oct 2, 2025
Merged

feat: OpenDB api now sets few configs passed via options#1675
kavirajk merged 1 commit intomainfrom
kavirajk/opendb-api-settings-fix

Conversation

@kavirajk
Copy link
Copy Markdown
Contributor

@kavirajk kavirajk commented Oct 1, 2025

Summary

Currently, some settings passed via Options are not set in sql.DB connection in OpenDB() api. These configs include

  1. MaxIdleConns
  2. MaxOpenConns
  3. ConnMaxLifetime

Passing these configs will result in error asking user to set those manually via returned sql.DB connection.

This PR fixes it by respecting those configs passed in via Options and sets in the connection before return. Makes it consistent with Open() api causing less confusion.

NOTE: It's hard to write test for this one without using reflection (to interpret non-exported private fields of sql.DB). So trusting on just existing test cases.

Checklist

Delete items not relevant to your PR:

Currently, some settings passed via Options are not set in sql.DB
connection in OpenDB() api. These configs include
1. MaxIdleConns
2. MaxOpenConns
3. ConnMaxLifetime

Passing these configs will result in error asking user to set those
manually via returned sql.DB connection.

This PR fixes it by respecting those configs passed in via Options and
sets in the connection before return. Makes it consistent with Open()
api causing less confusion.

Signed-off-by: Kaviraj <[email protected]>
@kavirajk kavirajk merged commit 437b4b1 into main Oct 2, 2025
14 checks passed
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