Refactor database connection handling and streamline show commands#449
Merged
Conversation
…and clean up test cases
…d improve error management
- Removed the `testInsertAndQuery` function from `machsvr_test.go` and integrated its logic into `spi_test.go` for better organization and clarity. - Updated the `ShowTags` function in `show.go` to use the new query handling approach, replacing the previous method of describing tables. - Modified the `ListTagsWalk` and `QueryTagStat` functions to accept `*sql.Conn` instead of `api.Conn`, ensuring consistency in connection handling. - Enhanced the `TestShowTables` function in `show_test.go` to correctly parse time without unnecessary timezone conversions. - Cleaned up the `InsertAndQuery` function in `tables.go` by removing redundant code and ensuring it follows the new query execution pattern. - Updated the `TestAll` function in `testsuite.go` to remove the now redundant `InsertAndQuery` test case. - Refactored the `unit_test.go` to streamline the stub connection implementation and improve error handling in test scenarios.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #449 +/- ##
==========================================
- Coverage 65.95% 65.92% -0.04%
==========================================
Files 345 343 -2
Lines 70557 70286 -271
==========================================
- Hits 46533 46333 -200
+ Misses 19087 18997 -90
- Partials 4937 4956 +19 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors database connection handling and SQL execution across the codebase to standardize on Go's
database/sqlpackage and improve consistency, reliability, and maintainability. It replaces custom connection interfaces with*sql.Conn, updates function signatures, and refactors SQL execution logic in server handlers and TQL modules. Additionally, it modernizes error handling and improves test diagnostics.Database connection and execution refactoring:
Replaced custom
api.Connusage with*sql.Connfrom the standard library throughout the server and TQL modules, updating function signatures and connection acquisition logic accordingly. (mods/server/http.go,mods/server/http_query.go,mods/server/http_write.go,mods/tql/fm_dbsink.go,mods/tql/fm_dbsrc.go) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14]Refactored SQL execution paths to use context-aware methods (
ExecContext,QueryRowContext) and improved error propagation and handling. (mods/server/http_write.go,mods/tql/fm_dbsink.go,mods/tql/fm_dbsrc.go) [1] [2] [3] [4]Server handler improvements:
Updated HTTP handlers to use the new connection methods, added stricter authorization checks for license installation, and improved resource cleanup with proper
deferusage. (mods/server/http.go) [1] [2] [3]Changed table listing logic to pass errors directly and improved callback signatures for clarity. (
mods/server/http_query.go)TQL module enhancements:
mods/tql/fm_dbsink.go,mods/tql/fm_dbsrc.go) [1] [2] [3] [4]Testing and dependency updates:
Improved test diagnostics by including response bodies in assertion messages for easier debugging. (
mods/server/http_test.go)Updated dependency version for
github.com/machbase/neo-clientingo.mod.