-
Notifications
You must be signed in to change notification settings - Fork 32
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
Groups are not applied correclty in slices. #28
Comments
I'm not sure I undestand. You give Would be great if you'd give me a link to an example playground (e.g. on play.golang.org) with the buggy behaviour 👍 |
I am confused myself now. I tried to reproduce the behaviour, but now its behaving correctly. This is my example so far. I will try to get it to show the behaviour i described. Don't close yet pls. |
In my machine this is returning: {
"edges": {
"users": [
{
"edges": {},
"id": 1
}
]
},
"id": 1
} Running it on the play.golang.org site however correctly returns: {
"edges": {
"users": [
{
"id": 1
}
]
},
"id": 1
} I do not get it. |
Which Go version do you use? I copied your example and it works correctly on my machine. |
Tried with go 1.15 and 1.14.9 (which is the same as the playground uses). I think we can close it then. If i get it to reproduce on playground i will notice you here. |
It is reproducible on here. You need to run Add this to the root for database-config. // config.yaml
database:
host: "localhost"
password: "nopass"
name: "todo_ent"
user: "root"
port: "3308" |
I found the issue: https://github.com/liip/sheriff/blob/master/sheriff.go#L194 Your entities implement Stringer: https://github.com/masseelch/go-api-skeleton/blob/3c0c2b8dcebf22cc72176a46cdd15d7d4b4ed868/ent/user.go#L127 You can implement func (u *User) Marshal(options *sheriff.Options) (interface{}, error) {
return sheriff.Marshal(options, u)
} This is a bit unfortunate In your case I guess 🤔 Can you adjust the generated code? (well, you can always add this code in another file in the same package, but that's probably a bit ugly). |
That'd be a solution. But it is indeed a bit ugly. Maybe there is a way to not generate the
I have no idea how. But i am not very experienced (yet). |
I have the following structs:
Calling
sheriff.Marshal(&sheriff.Options{Groups: []string{"job:list", "user:list"}}, job)
on aJob
-struct results in theEdges
property of the attached users to be included in the resulting map. I'd expect it not be there since the groups given tosheriff.Marshal()
arejob:list
anduser:list
but theEdges
-property has none of the given groups attached.Example output:
The text was updated successfully, but these errors were encountered: