-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[minor issue] Realm Core throws due schema mismatch, even if deleteRealmIfMigrationNeeded is set to true #3577
Comments
Is the issue you're raising the fact that an exception is used internally to communicate the schema mismatch? If so, why do you feel that is an issue? |
Yes, I'm just wondering why an exception is used for something that works just fine. I've been told a number of times using error handling mechanisms to implement logic was wrong (and I feel that way myself too) |
A case could be made to avoid using exceptions for our implementation control flow, but this is an entirely internal codebase consideration, and something with very minimal impact given that we'll need to continue compiling our ObjC++ files with ARC's exception handling overhead for the large amount of core exception to NSError conversion. As far as I can recall, the only place we do this is for this feature, which should be fully ported to the object store in the near future anyway, avoiding the need to throw & catch that exception. For these reasons, I'm closing this issue. |
I believe I have the same issue, and I am unclear from reading the above comments how to fix it. I have a schema mismatch, and I would like Realm to delete on migration. My code is essentially the same as above:
And this crashes my app on the second line (or during first Realm access if I omit that line) with the following error:
Do I just catch it and assume everything is okay? Or do I need to do something else in my code? I've searched the Realm overview, docs, and google, and I don't know how to fix this, so |
Your problem is entirely unrelated to this issue. |
Ahhhhhh that makes a lot more sense. I missed that finer point. Thank you :) |
Goals
Release 0.102.0 includes the following enhancement "Add deleteRealmIfMigrationNeeded to RLMRealmConfiguration/Realm.Configuration. When this is set to true, the Realm file will be automatically deleted and recreated when there is a schema mismatch rather than migrated to the new schema."
Discussion: This is a relatively minor problem because the exception is swallowed at RLMRealm.mm:406 but I'm just wondering if this feature is supposed to be available across threads shouldn't
deleteRealmIfMigrationNeeded
be handled at core level instead of throwing and handling this in the C++ library? E.g. if this is an intended behavior should the core use exceptions to talk to the bindings to implement logic?Expected Results
I expect when I have a schema mismatch calling "Realm()" to simply delete the old file and keep on.
Actual Results
Realm()
throws an exception about schema mismatchSteps to Reproduce
code below
Code Sample
Here's the code to reproduce (provided you have a schema mismatch):
Version of Realm and Tooling
Realm version: via CocoaPods
Using Realm (0.102.0)
Using RealmSwift (0.102.0)
Xcode version: Version 7.3.1 (7D1014)
iOS/OSX version: Version 9.3 (SimulatorApp-645.9
Dependency manager + version: CocoaPods 1.0.0 (release)
The text was updated successfully, but these errors were encountered: