-
Notifications
You must be signed in to change notification settings - Fork 172
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
Immutable schema mode doesn't correctly handle changes #4901
Comments
This is working as intended. The idea is that only schema changes which require bumping the schema version should require regenerating your bundled Realm file, and not adding or removing types. The SDK should return a default-initialized Results (i.e. a Results in the Empty mode) for queries where the Table doesn't exist, which behaves nearly identically to a Results on an empty table. |
I'm not sure this is intuitive for users. This way we don't offer any sort of feedback that they may have a configuration error. A table being empty and a table not existing is not the same thing and it may be confusing that we're silently ignoring this particular mismatch. On the other hand, if that's the current behavior, it's likely that people haven't complained enough, so maybe that's what they want. I'll look into aligning .net to the other SDKs. |
Tables are an implementation detail, and any way to distinguish a table not existing from an empty table other than reading the schema from a file is probably a bug. Adding new types to the schema and opening a Realm silently creates the tables required, and this is just doing the same operation without actually modifying the file. |
Okay, I was able to get this to work by roughly porting what Cocoa does, thanks! |
Expected results
Opening a readonly Realm with schema different from what is on disk should fail.
Actual Results
Realm is opened successfully and the schema on disk is used.
Steps & Code to Reproduce
Foo
.Foo
andBar
and setschema_mode = SchemaMode::Immutable
.This appears to end up here:
realm-core/src/realm/object-store/shared_realm.cpp
Lines 256 to 262 in 1f08269
After which a lot of macro magic is happening. Ultimately, I would assume that if anything on the schema changes, OS should report that as an error. Otherwise, a user will open a Realm, happily work with it, then when they try query for
Bar
objects, they'd get an obscure error.Core version
Core version: 11.4.1
The text was updated successfully, but these errors were encountered: