Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for integer types in compare function to resolve Force Value attributes issue #33

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fharsanto
Copy link

@fharsanto fharsanto commented Oct 29, 2024

Features and Changes

This PR addresses the 'Force Value attributes issue' where the compare function only accepted float64 type data, limiting compatibility with integer attributes in GrowthBook. The function has been enhanced to accept int, int32, and int64 types, aligning with GrowthBook's number attribute specifications (which can be float or integer).

Changes

  • Extended compare function to support int, int32, and int64 types
  • Added type checking and conversion to ensure safe comparisons across these numeric types
  • Enhanced error logging for type mismatches
    These updates improve flexibility and ensure the compare function fully supports all numeric attributes in GrowthBook.

Testing

Running tool: /usr/bin/go test -timeout 60s -coverprofile=/tmp/vscode-gomFKWAE/go-code-cover -run ^TestCompare$ github.com/growthbook/growthbook-golang -v

=== RUN   TestCompare
--- PASS: TestCompare (0.00s)
PASS
coverage: 2.1% of statements
ok  	github.com/growthbook/growthbook-golang	0.011s	coverage: 2.1% of statements

Screenshots

image
image

@fharsanto fharsanto changed the title compare attributes should support int, int32, int64 Support for int, int32, and int64 in JSON value comparisons Oct 29, 2024
@fharsanto fharsanto changed the title Support for int, int32, and int64 in JSON value comparisons Add support for integer types in compare function to resolve Force Value attributes issue Oct 29, 2024
@fharsanto
Copy link
Author

Hello @ian-ross can you check on this?

@ian-ross
Copy link
Collaborator

@fharsanto I no longer work for Growthbook. I'm not sure who is responsible for the Go SDK now. @jdorn might be able to suggest someone to review this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants