Fix select with association column

This commit is contained in:
Jinzhu 2022-07-13 18:26:35 +08:00
parent cae30e9a50
commit 3262daf8d4
1 changed files with 1 additions and 1 deletions

View File

@ -672,7 +672,7 @@ func (stmt *Statement) SelectAndOmitColumns(requireCreate, requireUpdate bool) (
}
} else if field := stmt.Schema.LookUpField(column); field != nil && field.DBName != "" {
results[field.DBName] = true
} else if matches := nameMatcher.FindStringSubmatch(column); len(matches) == 3 && matches[1] == stmt.Table {
} else if matches := nameMatcher.FindStringSubmatch(column); len(matches) == 3 && (matches[1] == stmt.Table || matches[1] == "") {
results[matches[2]] = true
} else {
results[column] = true