dflourusso / expo-sqlite-orm

Expo SQLite ORM
132 stars 34 forks source link

Add defaults before persisting .create #34

Open wasabigeek opened 3 years ago

wasabigeek commented 3 years ago

Fixes #33

wasabigeek commented 3 years ago

@dflourusso appreciate your comments!

dflourusso commented 3 years ago

Thanks for your contribution. I will review your code ASAP. I don't know if the proposed solution is the best. For example, should i apply the default values to update too?

wasabigeek commented 3 years ago

That's a good question, maybe we can think of it similarly to how column defaults are handled in sql databases? If I understood correctly, it will set defaults on update too, if the fields are empty.

dflourusso commented 3 years ago

Another question, in the update method, i don't need to pass all model properties, then make sense not apply the defaultsvalues , what do you think?

wasabigeek commented 3 years ago

To clarify, if we are updating a column A, it shouldn't set column B to it's default value, even if it's empty? I agree, it seems like that's the default SQLite behaviour is, which I think we should follow.