mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-09 13:55:49 +00:00
fix for upgrading optional date properties
This commit is contained in:
parent
47776d9b0a
commit
027d4fd153
11
CHANGELOG.md
11
CHANGELOG.md
@ -1,3 +1,14 @@
|
||||
x.x.x Release notes (yyyy-MM-dd)
|
||||
=============================================================
|
||||
### Breaking changes
|
||||
* None
|
||||
|
||||
### Enhancements
|
||||
* None
|
||||
|
||||
### Bugfixes
|
||||
* Fix for crash when updating Realms with optional date properties to the new file format
|
||||
|
||||
0.13.1 Release notes (2016-5-24)
|
||||
=============================================================
|
||||
### Breaking changes
|
||||
|
3
Realm.xcworkspace/contents.xcworkspacedata
generated
3
Realm.xcworkspace/contents.xcworkspacedata
generated
@ -13,7 +13,4 @@
|
||||
<FileRef
|
||||
location = "group:examples/ReactExample/ios/ReactExample.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:src/node/RealmNode.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
|
@ -267,6 +267,9 @@ static void convert_outdated_datetime_columns(const SharedRealm &realm) {
|
||||
}
|
||||
|
||||
for (size_t row_index = 0; row_index < table->size(); row_index++) {
|
||||
if (table->is_null(property.table_column, row_index)) {
|
||||
continue;
|
||||
}
|
||||
auto milliseconds = table->get_timestamp(property.table_column, row_index).get_seconds();
|
||||
table->set_timestamp(property.table_column, row_index, Timestamp(milliseconds / 1000, (milliseconds % 1000) * 1000000));
|
||||
}
|
||||
|
Binary file not shown.
Binary file not shown.
@ -479,14 +479,20 @@ module.exports = BaseTest.extend({
|
||||
|
||||
// test file format upgrade
|
||||
var realm_v3 = new Realm({path: 'dates-v3.realm', schema: [schemas.DateObject]});
|
||||
TestCase.assertEqual(realm_v3.objects('Date').length, 1);
|
||||
TestCase.assertEqual(realm_v3.objects('Date').length, 2);
|
||||
TestCase.assertEqual(realm_v3.objects('Date')[0].currentDate.getTime(), 1462500087955);
|
||||
TestCase.assertEqual(realm_v3.objects('Date')[0].nullDate.getTime(), 1462500087955);
|
||||
TestCase.assertEqual(realm_v3.objects('Date')[1].currentDate.getTime(), -10000);
|
||||
TestCase.assertEqual(realm_v3.objects('Date')[1].nullDate, null);
|
||||
|
||||
// get new file format is not upgraded
|
||||
var realm_v5 = new Realm({path: 'dates-v5.realm', schema: [schemas.DateObject]});
|
||||
TestCase.assertEqual(realm_v5.objects('Date').length, 1);
|
||||
TestCase.assertEqual(realm_v5.objects('Date')[0].currentDate.getTime(), 1462500087955);
|
||||
|
||||
TestCase.assertEqual(realm_v5.objects('Date').length, 2);
|
||||
TestCase.assertEqual(realm_v3.objects('Date')[0].currentDate.getTime(), 1462500087955);
|
||||
TestCase.assertEqual(realm_v3.objects('Date')[0].nullDate.getTime(), 1462500087955);
|
||||
TestCase.assertEqual(realm_v3.objects('Date')[1].currentDate.getTime(), -10000);
|
||||
TestCase.assertEqual(realm_v3.objects('Date')[1].nullDate, null);
|
||||
|
||||
// test different dates
|
||||
var realm = new Realm({schema: [schemas.DateObject]});
|
||||
realm.write(function() {
|
||||
|
@ -739,7 +739,7 @@ module.exports = BaseTest.extend({
|
||||
Realm.copyBundledRealmFiles();
|
||||
|
||||
var realm = new Realm({path: 'dates-v5.realm', schema: [schemas.DateObject]});
|
||||
TestCase.assertEqual(realm.objects('Date').length, 1);
|
||||
TestCase.assertEqual(realm.objects('Date').length, 2);
|
||||
TestCase.assertEqual(realm.objects('Date')[0].currentDate.getTime(), 1462500087955);
|
||||
|
||||
var newDate = new Date(1);
|
||||
|
@ -174,6 +174,7 @@ exports.NullQueryObject = {
|
||||
exports.DateObject = {
|
||||
name: 'Date',
|
||||
properties: {
|
||||
currentDate: 'date'
|
||||
currentDate: 'date',
|
||||
nullDate: { type: 'date', optional: true }
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user