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
..
2021-09-23 19:29:20 +08:00
2025-03-06 23:04:26 +08:00
2026-01-19 13:04:03 +08:00
2024-12-01 23:47:51 +08:00
2022-03-21 21:17:48 +08:00
2026-01-23 16:37:38 +08:00
2025-08-28 16:53:19 +08:00
2024-06-25 21:11:36 +08:00
2025-09-01 15:33:50 +08:00
2025-08-28 16:53:19 +08:00
2026-01-16 12:43:52 +08:00
2025-12-09 15:46:41 +08:00
2026-01-23 16:37:38 +08:00
2022-09-26 22:11:13 +08:00
2025-12-09 15:46:41 +08:00
2022-09-26 22:11:13 +08:00
2026-01-15 21:23:07 +08:00
2025-08-28 16:53:19 +08:00
2025-08-28 16:53:19 +08:00
2025-08-28 16:53:19 +08:00
2025-08-28 16:53:19 +08:00
2025-08-28 16:53:19 +08:00
2026-01-16 10:33:05 +08:00
2025-12-12 15:14:21 +08:00
2025-11-21 17:27:09 +08:00
2025-09-28 17:57:27 +08:00
2025-12-12 15:14:21 +08:00
2023-11-20 20:47:26 +08:00
2026-01-15 13:27:25 +08:00
2022-11-01 20:12:21 +08:00
2025-12-26 16:43:19 +08:00
2026-01-16 13:05:33 +08:00
2024-12-09 23:12:20 +08:00
2025-12-12 15:14:21 +08:00
2024-12-07 14:01:31 +08:00
2025-12-12 15:14:21 +08:00
2026-02-26 16:27:00 +08:00
2025-08-28 16:53:19 +08:00
2025-08-28 16:53:19 +08:00
2025-08-28 16:53:19 +08:00
2025-08-28 16:53:19 +08:00
2025-08-28 16:53:19 +08:00
2026-01-16 10:33:05 +08:00
2026-01-16 12:43:52 +08:00
2023-09-04 21:23:46 +08:00
2022-02-16 00:26:06 +08:00
2025-08-28 16:53:19 +08:00
2025-08-28 16:53:19 +08:00
2025-08-29 10:32:30 +08:00
2025-09-28 17:08:37 +08:00
2026-01-19 13:04:03 +08:00
2026-01-19 13:04:03 +08:00
2025-08-22 15:29:16 +08:00
2025-03-06 23:04:26 +08:00
2026-01-23 16:37:38 +08:00