mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-14 07:33:28 +01:00
Cannot upsert a value #211
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @tosbaha on GitHub (May 10, 2018).
I am trying to do basic operation and it is just doesn't work. I am directly copy pasting code from Readme.
I get following error,
Ok lets unwrap it
Ok lets try with NSNumber
What is the correct way to upsert a value?
In CoreData model editor, slug is set as string, counter is sat as Decimal.
@JohnEstropia commented on GitHub (May 11, 2018):
Your
counterproperty is anNSNumber, so you need to unbox if first:Personally, I would recommend to just set
countertoInt:@tosbaha commented on GitHub (May 11, 2018):
Thanks again. I guess my mistake was setting counter to Decimal. I set it up as Int32 in Model editor, and Int the class, and it worked. You can close the issue.
PS: Maybe it is also good idea to change documentation for updating because query returns an optional. Here is my upsert code for simple counter increase
@JohnEstropia commented on GitHub (Jun 10, 2018):
I'm closing this issue for now. I'm planning to change fetches and queries to be
throwsfunctions instead of returning an optional in the future.