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

executor: adds support for anonymous contained structs #371

Open
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
8 participants
@chris-ramon
Copy link
Member

chris-ramon commented Jul 28, 2018

Overview

Test plan

  • go test ./...
@0xApe

This comment has been minimized.

Copy link

0xApe commented Sep 14, 2018

HI, wondering if there is any chance to merge this?

@mrg0lden

This comment has been minimized.

Copy link

mrg0lden commented Oct 19, 2018

@chris-ramon @pavelnikolov Same question, would you please merge it?

@Niondir

This comment has been minimized.

Copy link

Niondir commented Oct 22, 2018

Same here

@chris-ramon

This comment has been minimized.

Copy link
Member Author

chris-ramon commented Oct 22, 2018

Thanks for letting us know how important this PR are for you guys.

I'll jump back to get this merge as soon as I get the chance today/tomorrow.

@chris-ramon chris-ramon force-pushed the anon-contained-struct branch from d376817 to d35d558 Oct 24, 2018

@coveralls

This comment has been minimized.

Copy link

coveralls commented Oct 24, 2018

Coverage Status

Coverage increased (+0.009%) to 91.787% when pulling d35d558 on anon-contained-struct into a7e15c0 on master.

Oscil8 added some commits Jan 30, 2018

Implement support for anonymous contained structs by extracting
defaultResolveStruct from DefaultResolveFn
@raininfall

This comment has been minimized.

Copy link

raininfall commented Nov 12, 2018

I think this will resolve the issue without using user-provided resolve function.

if typeField.Anonymous && typeField.Type.Kind() == reflect.Struct {
  anonymousResolvedValue, err := defaultResolveStruct(valueField, fieldName)
  if err != nil {
    return nil, err
  } else if anonymousResolvedValue != nil {
    return anonymousResolvedValue, nil
  }
}
@abraithwaite

This comment has been minimized.

Copy link

abraithwaite commented Mar 4, 2019

Just commented on the issue, but just saw this PR. I'm still interested in this!

return valueField.Interface(), nil
}
if typeField.Anonymous && typeField.Type.Kind() == reflect.Struct {
return defaultResolveStruct(valueField, fieldName)

This comment has been minimized.

@abraithwaite

abraithwaite Mar 6, 2019

There's a bug here. We return too early if an anonymous struct comes before a field we're looking for.

I think what we want to do is run through all the top-level fields first, then dive if the field wasn't found.
Repeat for all anonymous structs until it's found. If not found, then return nil, nil.

This comment has been minimized.

@abraithwaite

abraithwaite Mar 6, 2019

Here's a fix, sans a proper test:

abraithwaite@5decd5b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.