feat(contrib/drivers): more database drivers#4553
Conversation
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
…ey acquisition logic (#4546) `pgsql driver`中`getPrimaryKeys`未使用现有缓存,导致每次`insert`都会重新查询表字段
`gf gen dao`生成`entity`时支持数据库`uuid`类型字段生成`github.com/google/uuid`的`uuid.UUID`类型字段
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Pull request overview
This pull request adds first-class support for MariaDB, TiDB, OceanBase, and GaussDB as separate database drivers in the GoFrame ecosystem. Previously, these databases were handled through the MySQL driver based on protocol compatibility. The PR introduces dedicated driver packages for each database to allow for future extensibility and database-specific features.
Key Changes:
- Added new driver packages for MariaDB, TiDB, OceanBase, and GaussDB under
contrib/drivers/ - Implemented MariaDB-specific
TableFieldsmethod to improve field retrieval accuracy - Deprecated MariaDB-specific logic in the MySQL driver
- Updated documentation to reflect the new separate drivers
Critical Issue Identified:
The most significant issue is that the MySQL driver (contrib/drivers/mysql/mysql.go) still registers "mariadb" and "tidb" as driver names in its init function (line 30), which will conflict with the new dedicated drivers that also attempt to register these same names. This needs to be fixed before merging.
Reviewed changes
Copilot reviewed 15 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| contrib/drivers/tidb/tidb.go | New TiDB driver implementation wrapping MySQL driver |
| contrib/drivers/tidb/go.mod | Module definition for TiDB driver |
| contrib/drivers/tidb/go.sum | Dependencies for TiDB driver |
| contrib/drivers/oceanbase/oceanbase.go | New OceanBase driver implementation wrapping MySQL driver |
| contrib/drivers/oceanbase/go.mod | Module definition for OceanBase driver |
| contrib/drivers/oceanbase/go.sum | Dependencies for OceanBase driver |
| contrib/drivers/gaussdb/gaussdb.go | New GaussDB driver implementation wrapping MySQL driver |
| contrib/drivers/gaussdb/go.mod | Module definition for GaussDB driver |
| contrib/drivers/gaussdb/go.sum | Dependencies for GaussDB driver |
| contrib/drivers/mariadb/mariadb.go | New MariaDB driver implementation wrapping MySQL driver |
| contrib/drivers/mariadb/mariadb_table_fields.go | MariaDB-specific TableFields implementation with custom SQL query |
| contrib/drivers/mariadb/mariadb_unit_init_test.go | Test initialization code for MariaDB driver |
| contrib/drivers/mariadb/mariadb_unit_model_test.go | Comprehensive test suite for MariaDB driver functionality |
| contrib/drivers/mariadb/go.mod | Module definition for MariaDB driver |
| contrib/drivers/mariadb/go.sum | Dependencies for MariaDB driver |
| contrib/drivers/mysql/mysql_table_fields.go | Added deprecation notices for MariaDB-specific code |
| contrib/drivers/mysql/mysql_z_unit_init_test.go | Minor comment formatting fix |
| contrib/drivers/README.MD | Updated with separate sections for new drivers and installation instructions |
| cmd/gf/go.mod | Added dependencies for new drivers |
| cmd/gf/go.work | Added replace directives for new drivers |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This pull request adds first-class support for MariaDB, TiDB, OceanBase, and GaussDB as separate database drivers in the GoFrame ecosystem, rather than relying solely on MySQL compatibility. It introduces new driver packages for each database, updates documentation to reflect these additions, and adjusts dependency management files accordingly. The changes also deprecate the MariaDB-specific logic in the MySQL driver in favor of the new dedicated MariaDB driver.
New Database Driver Support
contrib/drivers/, each with their own Go module files and driver implementation that wraps the MySQL driver for protocol compatibility and future extensibility. [1] [2] [3] [4] [5] [6] [7]go.modandgo.workfiles for proper dependency resolution and local development. [1] [2]Documentation Updates
contrib/drivers/README.MDto include installation and import instructions for the new drivers, and clarified the supported drivers section with dedicated code examples for each. [1] [2]MariaDB Driver Enhancements
TableFieldsmethod and SQL query in the new driver, improving the accuracy of table field retrieval for MariaDB databases.Deprecation and Refactoring