mirror of
https://gitee.com/johng/gf
synced 2026-06-06 16:21:40 +08:00
## Summary - Fixed a bug where `Raw()` with `Where()` and `Count()`/`ScanAndCount()` was ignoring the Where conditions in Count queries - The issue was in `getFormattedSqlAndArgs()` which returned `nil` for `conditionArgs` without calling `formatCondition()` for Raw SQL in `SelectTypeCount` case ## Changes - Modified `database/gdb/gdb_model_select.go` to call `formatCondition()` for Raw SQL Count queries - Added comprehensive test cases for MySQL and PostgreSQL drivers - Fixed incorrect test expectation in `Test_Model_Raw` ## Test plan - [x] Added `Test_Issue4500` with 6 edge cases covering: - Raw SQL with WHERE + external Where condition - Raw SQL without WHERE + external Where condition - Raw + Where + ScanAndCount - Raw + multiple Where conditions - Raw SQL with no external Where (baseline) - Verify All() still works correctly - [x] All tests pass on PostgreSQL Closes #4500