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

Bug: none/null value from surrealdb doesn't map to nil value for golang pointers #176

Open
2 tasks done
agufagit opened this issue Nov 1, 2024 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@agufagit
Copy link

agufagit commented Nov 1, 2024

Describe the bug

none/null value from surrealdb doesn't map to nil value for golang pointers

If a field is defined as type option<bool> with none value, the golang struct for that field is IsDefault *bool, version v0.2.1 will map nil value to IsDefault, new version v0.3.0 will map *bool(false) to IsDefault.

My app has tristate values whereas nil value is meaningful

Steps to reproduce

DEFINE TABLE t SCHEMAFULL;
DEFINE FIELD i TYPE option<bool>;

CREATE t:1;
type TReturn struct {
  IsDefault *bool
}

result, err := surrealdb.Query[TReturn](conn, "SELECT i as is_default FROM ONLY t:1;", map[string]any{})

Expected behaviour

IsDefault is nil value, not *bool(false)

SurrealDB version

surreal 2.0.4

Contact Details

No response

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct
@agufagit agufagit added the bug Something isn't working label Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant