Skip to content

Commit 0890702

Browse files
committed
fix(gdb): strip quote chars from schema in Model.TableFields
When performing cross-database JOINs with soft-delete, the schema name parsed from `schema`.`table` format retains database-specific quote characters. These quoted schema names break information_schema WHERE clause queries in TableFields lookups. Strip quote characters from usedSchema in Model.TableFields, matching the existing unquoting pattern used for usedTable via guessPrimaryTableName. fixes gogf#4725
1 parent 6204c13 commit 0890702

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

database/gdb/gdb_model_utility.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ func (m *Model) TableFields(tableStr string, schema ...string) (fields map[strin
3737
usedTable = m.db.GetCore().guessPrimaryTableName(tableStr)
3838
usedSchema = gutil.GetOrDefaultStr(m.schema, schema...)
3939
)
40+
// Strip quote characters from schema name, as it may come from cross-database
41+
// table parsing (e.g., `schema`.`table`) and contain database-specific quote chars.
42+
charL, charR := m.db.GetChars()
43+
if usedSchema != "" && (charL != "" || charR != "") {
44+
usedSchema = gstr.Trim(usedSchema, charL+charR)
45+
}
4046
// Sharding feature.
4147
usedSchema, err = m.getActualSchema(ctx, usedSchema)
4248
if err != nil {

0 commit comments

Comments
 (0)