-
Notifications
You must be signed in to change notification settings - Fork 92
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
config inMemory #280
config inMemory #280
Conversation
Pull Request Test Coverage Report for Build 1945207203
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer Configuration
to be immutable, ie. to drop the public setters, so that everything must be set on construction. We hold a reference to the Configuration
from a Realm
. You cannot really manipulate the Configuration
after you have opened the Realm
, so why allow stuff like realm.Configuration.inMemory = true
in the type system (even if it does throw an exception).
On round-table today, we decided to merge as is, and defer making |
Co-authored-by: Kasper Overgård Nielsen <[email protected]>
lib/src/configuration.dart
Outdated
@@ -39,14 +39,19 @@ class Configuration { | |||
/// [readOnly] controls whether a [Realm] is opened as readonly. | |||
/// This allows opening it from locked locations such as resources, | |||
/// bundled with an application. The realm file must already exists. | |||
Configuration(List<SchemaObject> schemaObjects, {bool readOnly = false}) | |||
/// | |||
/// If [inMemoryOnly] is set, then the [Realm] instance will not be persisted, and hence be _deleted_ after it is closed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think other SDKs have different doc here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please check this comment: #280 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a review with a suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Co-authored-by: blagoev <[email protected]>
lib/src/configuration.dart
Outdated
/// Gets or sets a value specifying settings for an in-memory Realm. | ||
/// When all in-memory instance of Realm is closed all data in that Realm is deleted. | ||
bool get inMemory => realmCore.getConfigInMemory(this); | ||
set inMemory(bool value) => realmCore.setConfigInMemory(this, value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name diverges with isReadOnly
we could syncing it. So isInMemory
or we rename isReadOnly
to readOnly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to isInMemory .
test/configuration_test.dart
Outdated
expect(Realm.existsSync(config.path), false); | ||
}); | ||
|
||
test('Configuration inMemory - lost objects after closing', () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could delete this test. Does not make much sense to test that if it is inMemory only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleted.
test/configuration_test.dart
Outdated
realm.close(); | ||
}); | ||
|
||
test('Configuration inMemory and readOnly', () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is testing readonly instead of inMemory. I suggest delete it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleted.
Co-authored-by: blagoev <[email protected]>
Co-authored-by: blagoev <[email protected]>
Implemented inMemory property of realm configuration. Fixes #91