fix(contrib/drivers/mssql): update tables SQL query for better compatibility#4170
fix(contrib/drivers/mssql): update tables SQL query for better compatibility#4170hailaz merged 13 commits intogogf:masterfrom
Conversation
|
@li-zheng-hao 你好,我没有在 |
@li-zheng-hao Hello, I did not reproduce this problem on |
|
@gqcn 已补充测试用例,另外复现步骤如下:
|
…d enhance type handling
refactor(contrib/drivers/mssql): 优化 SQL 执行逻辑,简化条件判断
- 将 `github.com/emirpasic/gods` 从 v1.18.1 更新至 v2.0.0-alpha - 更新以下模块的 go.mod 和 go.sum 文件: - contrib/drivers/sqlitecgo - contrib/metric/otelmetric - contrib/nosql/redis - contrib/registry/consul - contrib/registry/etcd - contrib/registry/file - contrib/registry/nacos - contrib/registry/polaris - contrib/registry/zookeeper - contrib/rpc/grpcx - contrib/sdk/httpclient - contrib/trace/otlpgrpc - contrib/trace/otlphttp
There was a problem hiding this comment.
Pull request overview
This PR fixes SQL Server compatibility issues with the gf gen dao command by updating from deprecated system tables to modern catalog views, and upgrades the emirpasic/gods dependency to v2.
- Updated MSSQL driver to use
sys.objectsandsys.columnsinstead of deprecatedSYSOBJECTSandsyscolumns - Upgraded
github.com/emirpasic/godsfrom v1.18.1 to v2.0.0-alpha across all modules - Enhanced test coverage with proper test implementations and removed blocking test code
Reviewed changes
Copilot reviewed 34 out of 60 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| contrib/drivers/mssql/mssql_tables.go | Updated table listing query to use sys.objects for SQL Server 2005+ compatibility |
| contrib/drivers/mssql/mssql_table_fields.go | Modernized field metadata query using sys.columns with better type handling |
| contrib/drivers/mssql/mssql_do_exec.go | Refactored constants for clarity and modified rowsAffected calculation logic |
| contrib/drivers/mssql/mssql_z_unit_init_test.go | Added test database creation logic and updated to use modern SQL Server catalog views |
| contrib/drivers/mssql/mssql_z_unit_basic_test.go | Updated test schema references to use TestSchema constant |
| contrib/drivers/mssql/mssql_z_unit_model_test.go | Removed UID field from test data, commented out debug output, and removed blocking return statement |
| contrib/drivers/mssql/mssql_do_filter_test.go | Replaced empty test skeleton with comprehensive DoFilter test cases |
| contrib/drivers/mssql/go.mod | Updated gods dependency to v2.0.0-alpha |
| .github/workflows/scripts/ci-main.sh | Removed MSSQL test skip logic now that compatibility issues are resolved |
| [43 other go.mod/go.sum files] | Consistently updated gods dependency across all modules |
Comments suppressed due to low confidence (1)
contrib/drivers/mssql/mssql_z_unit_init_test.go:140
- Potential SQL injection vulnerability: Table names and column names are directly interpolated into SQL queries using
fmt.Sprintfwithout proper escaping. While these are test helper functions, this pattern could be copied to production code. Consider using proper identifier escaping for SQL Server (e.g.,QUOTENAME()function or bracket notation like[%s]) to prevent potential SQL injection if table names come from untrusted sources. Example:IF NOT EXISTS (SELECT * FROM sys.objects WHERE name='%s' and type='U') CREATE TABLE [%s] (...)
if _, err := db.Exec(context.Background(), fmt.Sprintf(`
IF NOT EXISTS (SELECT * FROM sys.objects WHERE name='%s' and type='U')
CREATE TABLE %s (
ID numeric(10,0) NOT NULL,
PASSPORT VARCHAR(45) NULL,
PASSWORD VARCHAR(32) NULL,
NICKNAME VARCHAR(45) NULL,
CREATE_TIME datetime NULL,
CREATED_AT datetimeoffset NULL,
UPDATED_AT datetimeoffset NULL,
PRIMARY KEY (ID))
`, name, name)); err != nil {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
refactor(contrib/drivers/mssql): 更新测试用例中的数据库和表创建语句,确保兼容性
修复gf gen在sqlserver上的异常问题:
在SqlServer 2022已测试通过: