You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The dataselect is well designed to filter、sort、paginate datacells. I want to reuse the dataselect module in my project. But I metioned that FilterQuery、SortQuery、PaginationQuery may be nil and cause panic error, for example
// Filter the data inside as instructed by DataSelectQuery and returns itself to allow method chaining.
func (self *DataSelector) Filter() *DataSelector {
filteredList := []DataCell{}
for _, c := range self.GenericDataList {
matches := true
for _, filterBy := range self.DataSelectQuery.FilterQuery.FilterByList {
v := c.GetProperty(filterBy.Property)
if v == nil || !v.Contains(filterBy.Value) {
matches = false
break
}
}
if matches {
filteredList = append(filteredList, c)
}
}
self.GenericDataList = filteredList
return self
}
when we iterate self.DataSelectQuery.FilterQuery.FilterByList, if the FilterQuery is nil, it will panic.
What would you like to be added?
The
dataselect
is well designed to filter、sort、paginate datacells. I want to reuse thedataselect
module in my project. But I metioned thatFilterQuery
、SortQuery
、PaginationQuery
may be nil and cause panic error, for examplewhen we iterate
self.DataSelectQuery.FilterQuery.FilterByList
, if theFilterQuery
is nil, it will panic.The use-case of my code is following:
Apart from QueryFilter, the
DataSelectQuery
should also be checked to avoid nil pointer error.Why is this needed?
For more robust, when the
dataselect
pkg is resued by other project.Tasks
The text was updated successfully, but these errors were encountered: