Skip to content

Commit

Permalink
Merge pull request #55 from statsig-io/fix-eq-neq-operator
Browse files Browse the repository at this point in the history
fix eq and neq operators
  • Loading branch information
jkw-statsig authored Feb 11, 2022
2 parents e21d231 + 568dbf4 commit 9d431a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,19 @@ func (e *evaluator) evalCondition(user User, cond configCondition) *evalResult {
pass = matched

// strict equality
case "eq":
pass = reflect.DeepEqual(value, cond.TargetValue)
case "neq":
pass = !reflect.DeepEqual(value, cond.TargetValue)
case "eq", "neq":
equal := false
// because certain user values are of string type, which cannot be nil, we should check for both nil and empty string
if cond.TargetValue == nil {
equal = value == nil || value == ""
} else {
equal = reflect.DeepEqual(value, cond.TargetValue)
}
if op == "eq" {
pass = equal
} else {
pass = !equal
}

// time
case "before":
Expand Down
2 changes: 1 addition & 1 deletion transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func newTransport(secret string, options *Options) *transport {

return &transport{
api: api,
metadata: statsigMetadata{SDKType: "go-sdk", SDKVersion: "1.2.0"},
metadata: statsigMetadata{SDKType: "go-sdk", SDKVersion: "1.2.1"},
sdkKey: secret,
client: &http.Client{},
options: options,
Expand Down

0 comments on commit 9d431a2

Please sign in to comment.