fix(database/gdb): skip field filtering when table/alias is unknown in FieldsPrefix (#4602)

## Summary
- Fix FieldsPrefix silently dropping fields when called before LeftJoin
- When table/alias is unknown, skip filtering and return fields directly

## Test plan
- [x] Added unit test Test_Issue4595 in pgsql driver
- [x] Test covers: FieldsPrefix before LeftJoin, Fields with prefix,
FieldsPrefix after LeftJoin

Closes #4595
This commit is contained in:
Jack Ling
2026-01-15 10:25:40 +08:00
committed by GitHub
parent 1ed4e0267a
commit 3e73e2d2cc
2 changed files with 96 additions and 0 deletions

View File

@ -68,6 +68,11 @@ func (m *Model) mappingAndFilterToTableFields(table string, fields []any, filter
if fieldsTable != "" {
hasTable, _ := m.db.GetCore().HasTable(fieldsTable)
if !hasTable {
if fieldsTable != m.tablesInit {
// Table/alias unknown (e.g., FieldsPrefix called before LeftJoin), skip filtering.
return fields
}
// HasTable cache miss for main table, fallback to use main table for field mapping.
fieldsTable = m.tablesInit
}
}