This commit is contained in:
John Guo
2022-10-13 19:13:10 +08:00
committed by GitHub
parent 55e8dbe9fd
commit c6a02b850d
2 changed files with 12 additions and 1 deletions

View File

@ -4688,3 +4688,14 @@ func Test_Builder_OmitEmptyWhere(t *testing.T) {
t.Assert(count, TableSize)
})
}
func Test_Issue1934(t *testing.T) {
table := createInitTable()
defer dropTable(table)
gtest.C(t, func(t *gtest.T) {
one, err := db.Model(table).Where(" id ", 1).One()
t.AssertNil(err)
t.Assert(one["id"], 1)
})
}

View File

@ -528,7 +528,7 @@ func formatWhereHolder(ctx context.Context, db DB, in formatWhereHolderInput) (n
return
}
// Usually a string.
whereStr := gconv.String(in.Where)
whereStr := gstr.Trim(gconv.String(in.Where))
// Is `whereStr` a field name which composed as a key-value condition?
// Eg:
// Where("id", 1)