From 027d4fd153a69129b8a1db116f9f591cb720dfeb Mon Sep 17 00:00:00 2001 From: Ari Lazier Date: Thu, 26 May 2016 13:17:19 -0700 Subject: [PATCH 1/2] fix for upgrading optional date properties --- CHANGELOG.md | 11 +++++++++++ Realm.xcworkspace/contents.xcworkspacedata | 3 --- src/js_realm.hpp | 3 +++ tests/data/dates-v3.realm | Bin 4096 -> 4096 bytes tests/data/dates-v5.realm | Bin 4096 -> 4096 bytes tests/js/object-tests.js | 14 ++++++++++---- tests/js/realm-tests.js | 2 +- tests/js/schemas.js | 3 ++- 8 files changed, 27 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 894a58dc..73f6a10b 100644 --- a/CHANGELOG.md +++ b/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 diff --git a/Realm.xcworkspace/contents.xcworkspacedata b/Realm.xcworkspace/contents.xcworkspacedata index 9eb61350..24dd9431 100644 --- a/Realm.xcworkspace/contents.xcworkspacedata +++ b/Realm.xcworkspace/contents.xcworkspacedata @@ -13,7 +13,4 @@ - - diff --git a/src/js_realm.hpp b/src/js_realm.hpp index 221f1d5c..10914035 100644 --- a/src/js_realm.hpp +++ b/src/js_realm.hpp @@ -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)); } diff --git a/tests/data/dates-v3.realm b/tests/data/dates-v3.realm index 23268dd39dd4d9d6f4333d8c2e47ed413558008e..3453c1806a1b7604ffddbd11f962f926e19bf572 100644 GIT binary patch literal 4096 zcmeHEAy30l5Wc&&r3+!nB(i^igr6{AB*=*g+*U>t$V%6=9Rs&yW^xGzIXQ`(L?RH# zN#qPkC5FJ=>ua~*@b5$~-@EU=_r0$R0$myAy>r+)Q3~Lgs}7)|L4Iz&^;g$uL?6D;68G_NFXwXf)%OGa~IE=$;mZfBm=Loo+i+%5H#{dbB{X0CSGId`>#)$;k=xSk9&M7 zeaJgrz{Mr+e}9gt%D!vne-`+Qf1;FNZYZ7ioC8=Py05s#4f3A8*J1s~i??ZqZ^+g^ zy2K}+tJ9AuU<6Ri3vAv&HF8B?=fnE!v$>0v_-s?@li#({PK{5Rz`1rRm|ycunE`%Yyvg`n}AKgCSVh=3D^W|0{=|l7vOM#h5!Hn literal 4096 zcmeH_p;H1;5XN`+V2*LbArgreXNX31V8&=5(BQ-i4hV0KQ!!hJ%vg*D1JP(S8Vp4K zge%SvEspNKdk>hgoAw2kef#Zx`+m?SuxEjJY#lUCf&k!{PZ=OE{ruj2mapP8x`@)q zo79RW9W znZJSx`uU6p!!12?!rpa~#KY8s@b5u4FR0@YwlRN?w0a-2buT_$oUDCh&o`*y6ru9{ zc}qq1$=s$sukPiGNY39-BKL(=ctott@fF{Z`>Y@Dj1TRP`xeje{uw?u`CXPX_p$%i zAO8}q{mG!Q{}|^_6PWSy0VJ2-o!Qv4*`rEW+owZ1CC|)BG$;WjpahhF5>Nt4KnW-T MC7=Y9z&{fB1=gl^MF0Q* diff --git a/tests/data/dates-v5.realm b/tests/data/dates-v5.realm index af99d455562c8e86e76c6462835af8912d0d7165..a2ea6a7a1426cff7db676f98c98aed24ffbf183c 100644 GIT binary patch literal 4096 zcmeHGF>ljA6n^jB85`P49y@yIfP|1TFk~zcq>LRZkp;D;SSmE6mg7>`B6aZ?sehnj z$BY>>p$-fkJ9f-aq)ZSYA$ZTeORQ1`CYHOwPv5=wz3<+4=Z=PQU8^c?KW;tqJbXGww2Iq^s;315pPg&0qrGAy;ha~I2J?xcyyD$AO z;R>dvo-IHj%Mu>v5pbE8{xb-rrtHsF(Q#S5@QL=0vMlN4)(G7@>UJ&QQeXPA4nbHE zjgD&IChlX^*XMJczWe+N1_0lGJbEdW-+om~>hCdsvT@UteZ!{$&*fa9;Jf&?pXBf2 zU*NRPr_;`tlWpFaT`hH`@AK;uz!bpdEtbCGPe2i0do_pPkGNUKY61~%5kx<~9+SuU z0>_dEiwDr==T>2PKZ;G@K1%W&{dL$Sj8YoVkoY|1{BjS40E4-~Kiorg5$61AOcylc z+Ywy%(au}5s?%Plx>)L9i-$Ch8~pwtr^|qmi1ZOLdCXSq4RjVSbpxI`)fRVH vbqd23tK0H!>#l2z9_prU>lM~@%Q@g2a1J;JoCD4Q=YVs-Ip7@le-8WxPjTn! literal 4096 zcmeHFF=!M~5S^KS>qbrB$}6`>A&9U=ij=1$V432;D}-c?TS#K^*<1DO0yc+Lz~;&; zQe1gpW0~@b6e&|$rck&_MG$?n`~PLZMy&r7JNy33yqS6bj}2AUb-wpt>roUDJ%p_h z8GBI2-FNL}US`j;GIKcIKgGOqZPX7oFzRP&I|>Q~`k=f&W~@ljRp&z1j@ zuISqFw~&WeWm<^A-|C}So zkG}k&fAOw|3O5&D^Vv4`TJr7jkL8}|SMjX~wSRqmBjCY27S~JU@sLijevS3s-7~7< zsE<3;5l-&OraTtaO#7;SLoI?S{ulkMoXA-I)~~q_=vevCS7tKTIsIOI*{Ij}L_Rm; zMs-_&-|f{(*+QGX@wiJvytnD9V$9##z@t%9T<=MSleS4rYHqvph$u?=3OqBJIbj@M z)TOra(GDJ|n&XW&dN;V{o#P(+#+s42TZh6oC=e6~3Iqj$0zrYGKu{nk5EKXs{FefM E0MOC9t^fc4 diff --git a/tests/js/object-tests.js b/tests/js/object-tests.js index ad13da1b..cf1ca398 100644 --- a/tests/js/object-tests.js +++ b/tests/js/object-tests.js @@ -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() { diff --git a/tests/js/realm-tests.js b/tests/js/realm-tests.js index 4ef5201d..cc0e2bfc 100644 --- a/tests/js/realm-tests.js +++ b/tests/js/realm-tests.js @@ -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); diff --git a/tests/js/schemas.js b/tests/js/schemas.js index 6eed754d..888ef44a 100644 --- a/tests/js/schemas.js +++ b/tests/js/schemas.js @@ -174,6 +174,7 @@ exports.NullQueryObject = { exports.DateObject = { name: 'Date', properties: { - currentDate: 'date' + currentDate: 'date', + nullDate: { type: 'date', optional: true } } }; From 118567ca4ebdf7d27555e41dde91d42c79e3f93f Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Thu, 26 May 2016 13:31:39 -0700 Subject: [PATCH 2/2] [0.13.2] Bump version --- CHANGELOG.md | 2 +- package.json | 2 +- scripts/publish.sh | 2 +- src/ios/RealmJS.xcodeproj/project.pbxproj | 12 ++++++------ 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73f6a10b..e8e9b35d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -x.x.x Release notes (yyyy-MM-dd) +0.13.2 Release notes (2016-5-26) ============================================================= ### Breaking changes * None diff --git a/package.json b/package.json index 7fc29330..42ea8fb0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "realm", "description": "Realm is a mobile database: an alternative to SQLite and key-value stores", - "version": "0.13.1", + "version": "0.13.2", "license": "Apache-2.0", "homepage": "https://realm.io", "keywords": [ diff --git a/scripts/publish.sh b/scripts/publish.sh index 68f3fed7..1137cf9c 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -82,7 +82,7 @@ rm -rf react-native/android/build # Publish to npm, informing the prepublish script to build Android modules. echo "Publishing $VERSION to npm..." -PRERELEASE=$(grep -Eio '[a-z]+' <<< "$VERSION") +PRERELEASE=$(grep -Eio '[a-z]+' <<< "$VERSION" || true) REALM_BUILD_ANDROID=1 npm publish ${PRERELEASE:+--tag $PRERELEASE} # Only push the tag to GitHub if the publish was successful. diff --git a/src/ios/RealmJS.xcodeproj/project.pbxproj b/src/ios/RealmJS.xcodeproj/project.pbxproj index 4f9083cc..4f085b4b 100644 --- a/src/ios/RealmJS.xcodeproj/project.pbxproj +++ b/src/ios/RealmJS.xcodeproj/project.pbxproj @@ -779,7 +779,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 0.13.1; + CURRENT_PROJECT_VERSION = 0.13.2; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -840,7 +840,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 0.13.1; + CURRENT_PROJECT_VERSION = 0.13.2; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -934,7 +934,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 0.13.1; + CURRENT_PROJECT_VERSION = 0.13.2; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; @@ -1001,7 +1001,7 @@ buildSettings = { DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 0.13.1; + DYLIB_CURRENT_VERSION = 0.13.2; EXECUTABLE_PREFIX = lib; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -1031,7 +1031,7 @@ isa = XCBuildConfiguration; buildSettings = { DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 0.13.1; + DYLIB_CURRENT_VERSION = 0.13.2; EXECUTABLE_PREFIX = lib; GCC_PREPROCESSOR_DEFINITIONS = ( "REALM_PLATFORM_NODE=1", @@ -1060,7 +1060,7 @@ isa = XCBuildConfiguration; buildSettings = { DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 0.13.1; + DYLIB_CURRENT_VERSION = 0.13.2; EXECUTABLE_PREFIX = lib; GCC_PREPROCESSOR_DEFINITIONS = ( "REALM_PLATFORM_NODE=1",