Implement database/sql driver with parameter binding and pooling#162
Implement database/sql driver with parameter binding and pooling#162wkk778 wants to merge 4 commits into
Conversation
… binding and connection pooling - Add complete database/sql driver interface implementation
# Conflicts: # .github/workflows/go.yml # go.mod # go.sum
There was a problem hiding this comment.
Pull request overview
This PR introduces a database/sql-compatible driver layer for the IoTDB Go client, including DSN parsing, parameter binding, and row/column scanning support, plus a suite of tests to validate basic query/scan behavior.
Changes:
- Register and implement an
iotdbdatabase/sql/driver(connect/open, ping, exec, query, rows). - Add DSN parsing + query parameter binding helpers (positional, numeric, named).
- Add column adapters and integration/unit tests for querying and scanning common IoTDB data types.
Reviewed changes
Copilot reviewed 33 out of 34 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| go.mod | Adds github.com/pkg/errors dependency used by the new driver/binding code. |
| go.sum | Updates sums for new dependencies. |
| client/session.go | Adds Session.Ping(ctx) used by the sql driver pinger. |
| database/iotdb.go | Introduces shared error values and transport abstractions used by the new driver. |
| database/iotdb_std.go | Implements database/sql/driver connection behavior and registers the iotdb driver. |
| database/std_connect.go | Defines the internal connection interface used by the stdlib driver wrapper. |
| database/std_conn_opener.go | Implements a driver.Connector-style opener with address selection strategy. |
| database/conn.go | Implements dialing and the pooled connection wrapper on top of client.SessionPool. |
| database/conn_exec.go | Adds Exec path that binds parameters then executes statements. |
| database/rows.go | Introduces internal rows wrapper around client.SessionDataSet. |
| database/rows_std.go | Implements driver.Rows for database/sql iteration and scanning. |
| database/options.go | Adds DSN parsing into Options and exposes driver/pool config fields. |
| database/query_parameters.go | Adds helper to decide between native parameters and legacy bind interpolation. |
| database/bind.go | Implements parameter interpolation (positional, numeric, named) and value formatting. |
| database/batch.go | Adds a statement-like type intended for batch/prepared usage (currently stubbed). |
| database/context.go | Defines query options stored in context and cloning/timeout behavior. |
| database/driver/driver.go | Adds internal parameter wrapper types (NamedValue, NamedDateValue). |
| database/column/column.go | Maps IoTDB type strings to column adapters for row value extraction. |
| database/column/bool.go | BOOLEAN column adapter. |
| database/column/int32.go | INT32 column adapter. |
| database/column/int64.go | INT64 column adapter. |
| database/column/float.go | FLOAT column adapter. |
| database/column/double.go | DOUBLE column adapter. |
| database/column/string.go | TEXT/STRING column adapter. |
| database/column/timestamp.go | TIMESTAMP column adapter. |
| database/column/date.go | DATE column adapter. |
| database/column/blob.go | BLOB column adapter. |
| database/options_test.go | Unit tests for DSN parsing behavior. |
| database/bind_test.go | Unit tests for binding/interpolation and formatting. |
| database/conn_integration_test.go | Integration tests for ping/pool/close/basic round trip. |
| database/query_test.go | Integration tests for core SELECT/WHERE query behaviors. |
| database/query_agg_test.go | Integration tests for aggregations/group-by/limit/align/metadata queries. |
| database/scan_types_test.go | Integration tests for scanning IoTDB primitive types and text values. |
| database/iotdb_std_test.go | Integration tests validating basic INSERT/SELECT via database/sql. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
HTHou
left a comment
There was a problem hiding this comment.
Thanks for taking on database/sql support. I found several correctness blockers around the driver contracts, result/session lifetime, NULL handling, and context propagation, so I’m requesting changes.
I verified the new package with go test -short ./database and go vet ./database. A full go test -short ./... attempt was killed locally during the Go linker step, so I do not have a full-repo test result from this machine.
…ove type handling - Add context support to ExecuteQueryStatement via new Option pattern - Implement proper zero value returns for all column types (blob, bool, date, double, float, int32, int64) - Replace stdBatch with stdStmt that implements full driver.Stmt interface - Fix parameter binding regex to properly handle escaped question marks - Improve connection pooling with timezone configuration and proper session management - Add transaction support reporting with appropriate error messages - Implement proper NULL value handling in row scanning - Add comprehensive test coverage for new features and edge cases - Introduce Options pattern for flexible client configuration - Enhance session lifecycle management with proper resource cleanup
|
|
No description provided.