9
9
"gorm.io/gorm/clause"
10
10
"net/url"
11
11
"reflect"
12
+ "strconv"
12
13
"strings"
13
14
)
14
15
@@ -724,11 +725,15 @@ func (afo *GormAdminFilterObjects) Search(field *Field, searchString string) {
724
725
if searchField .Field .FieldType .Kind () == reflect .Struct {
725
726
afo .Search (searchField .Field , searchString )
726
727
continue
727
- } else if (fieldType1 == reflect .Uint ) || (fieldType1 == reflect .Uint64 ) || (fieldType1 == reflect .Uint32 ) || (fieldType1 == reflect .Int64 ) || (fieldType1 == reflect .Int ) || (fieldType1 == reflect .Int32 ) || (fieldType1 == reflect .Float32 ) || (fieldType1 == reflect .Float64 ) {
728
+ } else if (fieldType1 == reflect .Uint ) || (fieldType1 == reflect .Uint64 ) || (fieldType1 == reflect .Uint32 ) || (fieldType1 == reflect .Int64 ) || (fieldType1 == reflect .Int ) || (fieldType1 == reflect .Int32 ) {
729
+ searchID , err1 := strconv .Atoi (searchString )
730
+ if err1 != nil {
731
+ continue
732
+ }
728
733
operator := ExactGormOperator {}
729
- operator .Build (afo .GetUadminDatabase ().Adapter , fullGormOperatorContext , searchField .Field , searchString , & SQLConditionBuilder {Type : "or" })
734
+ operator .Build (afo .GetUadminDatabase ().Adapter , fullGormOperatorContext , searchField .Field , searchID , & SQLConditionBuilder {Type : "or" })
730
735
operator = ExactGormOperator {}
731
- operator .Build (afo .GetUadminDatabase ().Adapter , paginatedGormOperatorContext , searchField .Field , searchString , & SQLConditionBuilder {Type : "or" })
736
+ operator .Build (afo .GetUadminDatabase ().Adapter , paginatedGormOperatorContext , searchField .Field , searchID , & SQLConditionBuilder {Type : "or" })
732
737
} else {
733
738
operator := IContainsGormOperator {}
734
739
operator .Build (afo .GetUadminDatabase ().Adapter , fullGormOperatorContext , searchField .Field , searchString , & SQLConditionBuilder {Type : "or" })
@@ -739,13 +744,17 @@ func (afo *GormAdminFilterObjects) Search(field *Field, searchString string) {
739
744
afo .SetFullQuerySet (fullGormOperatorContext .Tx )
740
745
afo .SetPaginatedQuerySet (fullGormOperatorContext .Tx )
741
746
afo .SetLastError (afo .PaginatedGormQuerySet .GetLastError ())
742
- } else if (fieldType == reflect .Uint ) || (fieldType == reflect .Uint64 ) || (fieldType == reflect .Uint32 ) || (fieldType == reflect .Int64 ) || (fieldType == reflect .Int ) || (fieldType == reflect .Int32 ) || (fieldType == reflect .Float32 ) || (fieldType == reflect .Float64 ){
747
+ } else if (fieldType == reflect .Uint ) || (fieldType == reflect .Uint64 ) || (fieldType == reflect .Uint32 ) || (fieldType == reflect .Int64 ) || (fieldType == reflect .Int ) || (fieldType == reflect .Int32 ){
748
+ searchID , err1 := strconv .Atoi (searchString )
749
+ if err1 != nil {
750
+ return
751
+ }
743
752
operator := ExactGormOperator {}
744
753
gormOperatorContext := NewGormOperatorContext (afo .GetFullQuerySet (), afo .GetCurrentModel ())
745
- operator .Build (afo .GetUadminDatabase ().Adapter , gormOperatorContext , field , searchString , & SQLConditionBuilder {Type : "or" })
754
+ operator .Build (afo .GetUadminDatabase ().Adapter , gormOperatorContext , field , searchID , & SQLConditionBuilder {Type : "or" })
746
755
afo .SetFullQuerySet (gormOperatorContext .Tx )
747
756
gormOperatorContext = NewGormOperatorContext (afo .GetPaginatedQuerySet (), afo .GetCurrentModel ())
748
- operator .Build (afo .GetUadminDatabase ().Adapter , gormOperatorContext , field , searchString , & SQLConditionBuilder {Type : "or" })
757
+ operator .Build (afo .GetUadminDatabase ().Adapter , gormOperatorContext , field , searchID , & SQLConditionBuilder {Type : "or" })
749
758
afo .SetPaginatedQuerySet (gormOperatorContext .Tx )
750
759
afo .SetLastError (afo .PaginatedGormQuerySet .GetLastError ())
751
760
} else {
0 commit comments