mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
## 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)