make nullable fields pointers

This commit is contained in:
Don Cote 2020-08-10 16:50:49 -04:00
parent 0e75c23b13
commit 54b759a134
5 changed files with 26 additions and 22 deletions

View File

@ -15,7 +15,7 @@ func makeCondition() segment.Condition {
Value: 100000000,
}
c := segment.Condition{
Gte: gte,
Gte: &gte,
}
return c
}
@ -44,7 +44,7 @@ func makeQuery(condition segment.Condition) dynamicquery.Query {
Value: "large_balance_holder",
}
filter := dynamicquery.Filter{
InSegment: inSegment,
InSegment: &inSegment,
}
query := dynamicquery.Query{

View File

@ -2,16 +2,16 @@ package dynamicquery
// Filter --
type Filter struct {
In In `json:"in,omitempty"`
NotIn NotIn `json:"not_in,omitempty"`
InSegment InSegment `json:"in_segment,omitempty"`
NotInSegment NotInSegment `json:"not_in_segment,omitempty"`
Gte Gte `json:"gte,omitempty"`
Lte Lte `json:"lte,omitempty"`
Gt Gt `json:"gt,omitempty"`
Eq Eq `json:"eq,omitempty"`
NotEq NotEq `json:"not_eq,omitempty"`
Lt Lt `json:"lt,omitempty"`
In *In `json:"in,omitempty"`
NotIn *NotIn `json:"not_in,omitempty"`
InSegment *InSegment `json:"in_segment,omitempty"`
NotInSegment *NotInSegment `json:"not_in_segment,omitempty"`
Gte *Gte `json:"gte,omitempty"`
Lte *Lte `json:"lte,omitempty"`
Gt *Gt `json:"gt,omitempty"`
Eq *Eq `json:"eq,omitempty"`
NotEq *NotEq `json:"not_eq,omitempty"`
Lt *Lt `json:"lt,omitempty"`
And []*Filter `json:"and,omitempty"`
Or []*Filter `json:"or,omitempty"`
}

4
go.mod
View File

@ -3,6 +3,6 @@ module github.com/FlipsideCrypto/flip-rpc-client-go
go 1.12
require (
github.com/mitchellh/mapstructure v1.3.1
github.com/pkg/errors v0.8.1
github.com/mitchellh/mapstructure v1.3.3
github.com/pkg/errors v0.9.1
)

4
go.sum
View File

@ -1,4 +1,8 @@
github.com/mitchellh/mapstructure v1.3.1 h1:cCBH2gTD2K0OtLlv/Y5H01VQCqmlDxz30kS5Y5bqfLA=
github.com/mitchellh/mapstructure v1.3.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/mapstructure v1.3.3 h1:SzB1nHZ2Xi+17FP0zVQBHIZqvwRN9408fJO8h+eeNA8=
github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=

View File

@ -26,12 +26,12 @@ type Gt struct {
// Condition is set of logic
type Condition struct {
PartitionID string `json:"partition_id,omitempty"`
Value float64 `json:"value,omitempty"`
PartitionID *string `json:"partition_id,omitempty"`
Value *float64 `json:"value,omitempty"`
Or []*Condition `json:"or,omitempty"`
And []*Condition `json:"and,omitempty"`
Gt Gt `json:"gt,omitempty"`
Gte Gte `json:"gte,omitempty"`
Lt Lt `json:"lt,omitempty"`
Lte Lte `json:"lte,omitempty"`
Gt *Gt `json:"gt,omitempty"`
Gte *Gte `json:"gte,omitempty"`
Lt *Lt `json:"lt,omitempty"`
Lte *Lte `json:"lte,omitempty"`
}