zendesk / android-db-commons

Some common utilities for ContentProvider/ContentResolver/Cursor and other db-related android stuff
Apache License 2.0
222 stars 28 forks source link

Update api improvement #4

Closed chalup closed 11 years ago

henieek commented 11 years ago

It's great addition and will make next release even better. Thanks! Anyway, I wonder if we should push the same functionality for Insert as well. There are definitely much more use-cases for that method in Update, but I can imagine some common scenarios when it could be very helpful in Insert, too. And it's very simple to implement. What we can do is just move this funky instanceof-and-cast logic to some ContentValuesWrapperCrap that will maintain its internal ContentValues instance. It could offer some toRealContentValues() method that would be later used in perform(). Bonus: If we find ContentValuesWrapperCrap contains some finer API than ContentValues itself we can move it later to the public API.

What's your opinion?

chalup commented 11 years ago

IMO you want to populate the content values for inserting from some POJO annotated with MicroOrm's @Column interface, and if you want to make some changes to those values, change the POJO before conversion to ContentValues.

I'd leave the insert be at the moment and add this funcitonality when needed.