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

hasMany association properties not being checked #49

Conversation

zachberry
Copy link
Contributor

(The following has been tested with the MySQL driver)

Consider the following hasMany relationship:

Person.hasMany('things', {
    price_paid: {type:'number'},
    year_bought: String
});

Now imagine sync is invoked on all tables. In 2.0.2 price_paid works fine, however year_bought results in a value of undefined being passed for the prop argument in buildColumnDefinition, and throws an error.

I poked around and I think this is due to the fact that Propertys check method is not transforming the types of any many_associations. The attached code is a simple copy/paste job that duplicates the check code from ORM.prototype.define into the Many class.

This fix allows both of the additional properties for this association to sync correctly.

I can help if more is needed or this should be organized in a different manner.

@dresende
Copy link
Owner

Thank you :)

dresende added a commit that referenced this pull request Feb 23, 2013
…-not-checked

hasMany association properties not being checked
@dresende dresende merged commit fb73b6e into dresende:master Feb 23, 2013
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling b3e6325 on zachberry:issue/has-many-assoc-properties-not-checked into * on dresende:master*.

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.

3 participants