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

adding arbitrary properties on schemafields #47

Merged
merged 3 commits into from
Mar 9, 2016
Merged

adding arbitrary properties on schemafields #47

merged 3 commits into from
Mar 9, 2016

Conversation

barnjamin
Copy link

No description provided.

return prop, true
}
}
return "", false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be return nil, false?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, good catch

@serejja
Copy link
Contributor

serejja commented Sep 16, 2015

I'm a bit concerned about consistency of Prop() functions. All schema Prop() calls return string, bool whereas this PR introduces Prop() (interface{}, bool).

I'm not sure why we implemented the string, bool version the way it forces values to be strings but for consistency sake what do you think about having this new (*SchemaField).Prop() returning string, bool as well? I'm ok if you really need to be able to get anything and not just strings.

I really don't want to make breaking changes so I'll rather leave it a bit inconsistent if you really need the interface{}, bool interface but please consider if it is possible to have string, bool in your case.

Thanks!

@barnjamin
Copy link
Author

I get that, I was thinking the same thing. Unfortunately I need an array for one of the properties and I'd like to avoid doing something like joining them as a string and splitting on some delimiter.

I can change the name of the function Prop to ArbitraryProp to draw a distinction. If thats the case, it may make sense to add that ArbitraryProp function to the other Schema structs and add it to the interface to allow the same functionality.

@serejja
Copy link
Contributor

serejja commented Sep 16, 2015

I like your approach. This way we could remove Prop in future releases (but not right now) because Prop and ArbitraryProp are nearly identical. I think it's ok to have them both for now not to break anyone and preserve consistency. Let's go for it.

@barnjamin
Copy link
Author

All the Properties maps in the Schema structs are map[string]string which doesn't support the ArbitraryProps function. Do you want to add another map[string]interface{} or change the current map and get rid of the type conversion in getProperties func and push it to the Prop func?

@serejja
Copy link
Contributor

serejja commented Sep 17, 2015

Ok I've had a night to think about that :)

In my opinion we have two options:

  • Breaking one. In this case I think it makes sense to tag/release the current master so that folks that wish to use the current approach could checkout to that tag/release. The master branch though would contain following changes:
    Properties map[string]string becomes Properties map[string]interface{} in all Schema implementations. This field is exported so there's a chance to break someone.
    Prop(key string) (string, bool) becomes Prop(key string) (interface{}, bool) in all Schema implementations + SchemaField
  • Non-breaking one. In this case we add one more map ArbitraryProperties map[string]interface{} besides the Properties map[string]string and add ArbitraryProp(key string) (interface{}, bool) to all Schema implementation + SchemaField.

The second one looks a bit ugly and workaround-ish to me.
I actually think it makes sense to go with first approach before folks start using the Prop() (string, bool) heavily. The less and earlier we break the better.

I'll talk to other collaborators today and let you know if they support this approach as well.
Thanks!

@serejja
Copy link
Contributor

serejja commented Sep 17, 2015

@barnjamin ok we agreed on the first approach, I'll create a release right now and then we could accept that breaking change.

Thanks!

@serejja
Copy link
Contributor

serejja commented Sep 17, 2015

@crast
Copy link
Contributor

crast commented Sep 18, 2015

@serejja could you use semantic versioning for breaking changes? This way you also have a path down the road for using the gopkg.in service

I would also propose that if you're thinking of going down the road, break everything you plan on breaking soon, and then get a stable API going.

@serejja serejja merged commit ab0d6ea into elodina:master Mar 9, 2016
serejja added a commit that referenced this pull request Mar 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants