Skip to content

Commit 2cba851

Browse files
committed
fix bugs
1 parent 57581d8 commit 2cba851

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

orm/query_where.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (q *Query[T]) WherePrimaryIfNotZero(val any) *Query[T] {
6464
}
6565
}
6666

67-
func (q *Query[T]) WhereFirstFieldIfNotZero(val any) *Query[T] {
67+
func (q *Query[T]) WhereStructPrimaryIfNotZero(val any) *Query[T] {
6868
rval := reflect.ValueOf(val)
6969
if rval.IsZero() {
7070
return q
@@ -78,6 +78,9 @@ func (q *Query[T]) WhereFirstFieldIfNotZero(val any) *Query[T] {
7878
if rval.NumField() == 0 {
7979
return q
8080
}
81+
if rval.Field(0).IsZero() {
82+
return q
83+
}
8184
return q.WherePrimary(rval.Field(0).Interface())
8285
}
8386
}

0 commit comments

Comments
 (0)