-
Notifications
You must be signed in to change notification settings - Fork 79
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
Pointer option #24
Pointer option #24
Conversation
Codecov Report
@@ Coverage Diff @@
## master #24 +/- ##
=======================================
Coverage 81.91% 81.91%
=======================================
Files 2 2
Lines 94 94
=======================================
Hits 77 77
Misses 16 16
Partials 1 1
Continue to review full report at Codecov.
|
Can we preserve BC by defaulting is pointer to is slice? |
If we need a bc break it might be time to parse a type string a little better, eg |
Yes. To preserve BC we need something like this:
IMHO this approach is not looks consistent and intuitive for users.
Good suggestion! I'll remove slice flag from https://github.com/vektah/dataloaden/blob/master/dataloaden.go#L13 and add type parsing. |
@vektah done, PTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry it took so long to review this.
Its a step in the right direction, I think we can probably leave it as a string though (its valid go code)
type ValueType struct {
Name string
ImportPath string
Prefix string
}
where prefix is captured by a simple repeating regex `^([]|*)*$``
} | ||
|
||
func NewValueTypeFromString(typeName string) (*ValueType, error) { | ||
valueTypeRegexp := regexp.MustCompile(`^(\[\])?(\*)?(.+)+\.(\w+)+$`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about [][]byte
?
or []*[]*string
prefix := "*" | ||
if slice { | ||
prefix := "" | ||
if valueType.IsSlice { | ||
prefix = "[]" | ||
data.LoaderName = name + "SliceLoader" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name generation probably also needs to be updated to handle these new cases, or let the user specify a name in case there are collisions.
I need this too. I would love to help in development but as I am still learning Go I don't know how. You are doing a great job. |
Closing in favor of #28 |
For now there is no way to return slice of pointers to value (common case in grpc for repeated fields).
Proposed add new
-pointer
flag that can works with/without-slice
option.This is backward incompatible change.