Jack Ling
e0c032d1b1
fix(database/gdb): handle empty string in Fields() gracefully (#4700)
## 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)
2026-02-26 16:27:00 +08:00
..
2025-11-21 17:27:09 +08:00
2026-01-26 20:37:48 +08:00
2025-12-03 23:42:16 +08:00
2025-08-28 16:53:19 +08:00
2024-12-11 09:58:26 +08:00
2026-01-07 17:32:16 +08:00
2024-01-30 20:03:58 +08:00
2025-08-28 16:53:19 +08:00
2025-09-26 11:11:14 +08:00
2025-09-26 11:11:14 +08:00
2026-02-26 09:53:35 +08:00
2026-02-26 09:53:35 +08:00
2024-01-30 20:03:58 +08:00
2024-01-30 20:03:58 +08:00
2026-02-26 09:53:35 +08:00
2024-01-30 20:03:58 +08:00
2025-08-28 16:53:19 +08:00
2025-08-28 16:53:19 +08:00
2024-01-30 20:03:58 +08:00
2024-12-09 23:12:20 +08:00
2025-08-28 16:53:19 +08:00
2024-01-30 20:03:58 +08:00
2026-02-26 09:53:35 +08:00
2024-11-23 18:35:02 +08:00
2024-01-30 20:03:58 +08:00
2025-08-28 16:53:19 +08:00
2024-01-30 20:03:58 +08:00
2025-06-20 19:11:01 +08:00
2025-12-09 16:33:55 +08:00
2024-10-21 09:22:53 +08:00
2026-02-26 16:27:00 +08:00
2026-01-16 13:05:33 +08:00
2024-12-09 09:24:48 +08:00
2025-03-17 14:50:07 +08:00
2025-12-09 16:33:55 +08:00