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: Readme example has errors in it #155

Closed
2 tasks done
nickchomey opened this issue Oct 9, 2024 · 2 comments
Closed
2 tasks done

Bug: Readme example has errors in it #155

nickchomey opened this issue Oct 9, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@nickchomey
Copy link

Describe the bug

When I run the readme code, it creates distinct columns depending on whether the person is created with map[interface{}]interface{}{} or the Person struct.

image

I changed the code so that it creates Jane Doe for the Person Struct, and it makes the columns lowercase because of the JSON annotations.

Should the map[interface{}]interface{}{} use lowercase for the fieldnames, like this

person1, err := surrealdb.Create[Person](db, models.Table("persons"), map[interface{}]interface{}{
		"name":     "John",
		"surname":  "Doe",
		"location": models.NewGeometryPoint(-0.11, 22.00),
	})

Or should the Person struct use uppercase in the json annotations?

Or should the sdk hande all of this automatically (perhaps automatically making all field names lowercase)?

Steps to reproduce

Run the readme code

Expected behaviour

That the two methods would use the same columns

SurrealDB version

latest

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
@nickchomey nickchomey added the bug Something isn't working label Oct 9, 2024
@remade
Copy link
Collaborator

remade commented Oct 25, 2024

Hi @nickchomey
This is a go related issue. The field names are dependent on the input. For struct types, with no JSON or CBOR tags, the column name will be the Field name else it will be the name on the tag. For example surrealdb.Auth has fields Username and Password; while the backend expects user and pass instead. If those fields weren't tagged, that would have been an invalid request.

It is best to leave the implementation to users

Will make an update to the readme

@nickchomey
Copy link
Author

nickchomey commented Oct 31, 2024

@remade It doesnt look like this was addressed in #163 - the readme is still the same, resulting in the issue reported here. Something should change, one way or the other, so that the Readme code works when someone tries to get started with this sdk.

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

2 participants