mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
e0c032d1b191b7d542f59b3d263da711ddcefc3a
## Summary
Fix bug where `Fields("")` with empty string generates invalid SQL
`SELECT FROM table`.
## Root Cause
`mappingAndFilterToTableFields` method doesn't skip empty strings when
processing fields:
- `gstr.SplitAndTrim("", ",")` returns empty array
- No fields added to query
- Results in invalid SQL: `SELECT FROM table`
## Fix
Skip empty string fields in `mappingAndFilterToTableFields` (line
97-100):
```go
// Skip empty string fields
if fieldStr == "" {
continue
}
```
## Behavior Changes
- `Fields("")` → SELECT * FROM table (uses default)
- `Fields("", "id")` → SELECT id FROM table (ignores empty string)
- `Fields("id", "", "nickname")` → SELECT id, nickname FROM table
## Tests
Added `Test_Issue4697` with 3 scenarios covering all cases above.
## Related
Fixes #4697
Ref #4703 (discovered during pagination test development)
refactor(container): add default nil checker, rename RegisterNilChecker to SetNilChecker, migrate instance containers to type-safe generics (#4630)
refract(gerror): add ITextArgs interface and its implements, mainly for i18n that needs text and args separately (#4597)
English | 简体中文
A powerful framework for faster, easier, and more efficient project development.
Installation
go get -u github.com/gogf/gf/v2
Documentation
- Official Site: https://goframe.org
- Official Site(en): https://goframe.org/en
- 国内镜像: https://goframe.org.cn
- Mirror Site: https://pages.goframe.org
- Mirror Site: Offline Docs
- GoDoc API: https://pkg.go.dev/github.com/gogf/gf/v2
- Doc Source: https://github.com/gogf/gf-site
Contributors
💖 Thanks to all the contributors who made GoFrame possible 💖
License
GoFrame is licensed under the MIT License, 100% free and open-source, forever.
Languages
GO
100%
