Skip to content

Commit

Permalink
fix: MQueryByIDs when ids is empty, nothing will be returned
Browse files Browse the repository at this point in the history
  • Loading branch information
dirac-lee committed Jun 19, 2023
1 parent dd9886b commit 8c84ea9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gdal.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func (gdal *GDAL[PO, Where, Update]) MQuery(ctx context.Context, where *Where, o
// FROM `user` WHERE `id` in (123, 456, 789) ORDER BY birthday LIMIT 10
func (gdal *GDAL[PO, Where, Update]) MQueryByIDs(ctx context.Context, ids []int64, options ...QueryOption) ([]*PO, error) {
where := &idWhere{
IDIn: ids,
IDIn: &ids,
}
var pos []*PO
err := gdal.Find(ctx, &pos, where, options...)
Expand Down Expand Up @@ -521,6 +521,6 @@ func buildQueryOptions(limit *int64, offset *int64, order *string) []QueryOption
}

type idWhere struct {
ID *int64 `sql_field:"id" sql_operator:"="`
IDIn []int64 `sql_field:"id" sql_operator:"in"`
ID *int64 `sql_field:"id" sql_operator:"="`
IDIn *[]int64 `sql_field:"id" sql_operator:"in"`
}

0 comments on commit 8c84ea9

Please sign in to comment.