Skip to content

Commit

Permalink
fix issue #1934
Browse files Browse the repository at this point in the history
  • Loading branch information
gqcn committed Oct 11, 2022
1 parent 35623b5 commit 3c242d5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions contrib/drivers/mysql/mysql_model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4665,3 +4665,14 @@ func TestResult_Structs1(t *testing.T) {
t.Assert(array[1].Name, "smith")
})
}

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)
})
}
2 changes: 1 addition & 1 deletion database/gdb/gdb_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3c242d5

Please sign in to comment.