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

Save() behaves different with annotated and extended entities #243

Closed
jivimberg opened this issue Jan 27, 2015 · 0 comments
Closed

Save() behaves different with annotated and extended entities #243

jivimberg opened this issue Jan 27, 2015 · 0 comments
Labels

Comments

@jivimberg
Copy link
Contributor

I've noticed that the following code will behave differently depending if the entity extends SugarRecord or if it's annotated with @Table

Car car = new Car("Nissan");
SugarRecord.save(car);

car.setName("Honda");
SugarRecord.save(car);

In the first case (extending) the second save() will replace the value of the row saved in the first save(), while in the annotated case it will save 2 different objects in the DB.

I understand why this is the case. When extending SugarRecord has an id field where it saves a reference of the row ID so in the second save it can tell that it's the same object. This is not true when using annotations.

This is a problem when trying to update an entity that's annotated. See #185

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/build.gradle
	sugartestapp/src/androidTest/java/me/jivimberg/android/sugartestapp/robolectric/SugarRecordTest.java
	sugartestapp/src/main/java/me/jivimberg/android/sugartestapp/model/annotated/Car.java
@whoshuu whoshuu added the bug label Apr 4, 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!
@whoshuu whoshuu closed this as completed in 6736197 Apr 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants