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

Bug in persisting relationships #215

Closed
Soben713 opened this issue Dec 18, 2014 · 1 comment
Closed

Bug in persisting relationships #215

Soben713 opened this issue Dec 18, 2014 · 1 comment

Comments

@Soben713
Copy link

After saving an entity with a foreign key the relationship field is null.
For example this is SubCategory:

@Table(name = "subcategory")
public class SubCategory extends SugarRecord {
    private String name;
    private Category category;
    private String slug;
    ...
}

And this is Category:

@Table(name = "category")
public class Category extends SugarRecord {
    @Column(name = "name", unique = true, notNull = true)
    private String name;
    private String slug;
    ...
}

But after subCategory is saved. If you get access to it by some query, its category field is null. This is how I save them:

Category category = new Category("Sample Category", "samplecategory");
SugarRecord.save(category);
SubCategory subCategory = new SubCategory("Sample Sub Category", "samplesub", category);
SugarRecord.save(subCategory);

Good news is that I found the bug in source code and am going to pull request.

Soben713 pushed a commit to Soben713/sugar that referenced this issue Dec 18, 2014
jivimberg added a commit to jivimberg/sugar that referenced this issue Jan 24, 2015
jivimberg added a commit to jivimberg/sugar that referenced this issue Jan 24, 2015
jivimberg added a commit to jivimberg/sugar that referenced this issue Jan 31, 2015
jivimberg added a commit to jivimberg/sugar that referenced this issue Feb 1, 2015
Conflicts:
	library/src/com/orm/SugarRecord.java
@MWalid
Copy link

MWalid commented Feb 8, 2015

Have same issue .... ur fix worked ..... u saved me...

whoshuu pushed a commit that referenced this issue Apr 7, 2015
whoshuu added a commit that referenced this issue Apr 7, 2015
Closes #254
References #185
References #215
References #243

Thanks @jivimberg for the pull request!
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

No branches or pull requests

2 participants