Skip to content

Commit

Permalink
keep resource hash as string
Browse files Browse the repository at this point in the history
Signed-off-by: Avraham Shalev <[email protected]>
  • Loading branch information
avrahams committed Apr 10, 2024
1 parent 73cc34f commit b17e55e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions handlers/v2ListRequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ func buildInnerFilter(ctx *gin.Context, innerFilter map[string]string) (*db.Filt

func getTypedValue(ctx *gin.Context, field, value string) (interface{}, error) {
schemaInfo := db.GetSchemaFromContext(ctx)
if schemaInfo.IsString(field) {
return value, nil
}
if schemaInfo.IsDate(field) {
date, err := time.Parse(time.RFC3339, value)
if err != nil {
Expand Down
5 changes: 4 additions & 1 deletion routes/v1/integration_reference/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ func AddRoutes(g *gin.Engine) {
schemaInfo := types.SchemaInfo{
ArrayPaths: []string{"relatedObjects"},
FieldsType: map[string]types.FieldType{
"creationTime": "date",
"creationTime": types.Date,
//add explicit string type to avoid conversion of query values to float
"owner.resourceHash": types.String,
"owner.repoHash": types.String,
},
}

Expand Down
7 changes: 7 additions & 0 deletions types/api_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ type FieldType string

const (
Date FieldType = "date"
//Use this is you field is a number or a boolean that is saved as a string
String FieldType = "string"
)

type SchemaInfo struct {
Expand Down Expand Up @@ -62,3 +64,8 @@ func (s *SchemaInfo) IsDate(field string) bool {
fieldType, exist := s.FieldsType[field]
return exist && fieldType == Date
}

func (s *SchemaInfo) IsString(field string) bool {
fieldType, exist := s.FieldsType[field]
return exist && fieldType == String
}

0 comments on commit b17e55e

Please sign in to comment.