fix: initialize catalog from connection properties#320
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Code Review
This pull request initializes the catalog field in the AbstractConnection constructor using the database name property and adds corresponding unit tests. The reviewer pointed out that this change introduces redundancy and potential state inconsistency because several subclasses maintain their own local database fields. It is recommended to refactor these subclasses to rely solely on the inherited catalog field from AbstractConnection.
There was a problem hiding this comment.
Pull request overview
This PR initializes Connection.getCatalog() from the incoming connection Properties (specifically TSDBDriver.PROPERTY_KEY_DBNAME) so a newly created connection reflects the configured database/catalog immediately.
Changes:
- Set
AbstractConnection.catalogfromproperties.getProperty(TSDBDriver.PROPERTY_KEY_DBNAME)during construction. - Refactor
AbstractConnectionTestsetup to use a helper constructor method. - Add unit tests verifying catalog initialization from properties and the null case when the property is absent.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/main/java/com/taosdata/jdbc/AbstractConnection.java |
Initialize catalog from connection properties during AbstractConnection construction. |
src/test/java/com/taosdata/jdbc/AbstractConnectionTest.java |
Add tests ensuring getCatalog() reflects dbname from properties (or null when missing). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #320 +/- ##
============================================
- Coverage 80.18% 80.13% -0.06%
+ Complexity 4465 4463 -2
============================================
Files 227 227
Lines 13491 13492 +1
Branches 1797 1797
============================================
- Hits 10818 10812 -6
- Misses 1754 1759 +5
- Partials 919 921 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Description
initialize catalog from connection properties
Issue(s)
Checklist
Please check the items in the checklist if applicable.