diff --git a/CHANGELOG.md b/CHANGELOG.md index 807b0d617..dd9ed42bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,11 @@ * None ### Fixed -* None +* [sane_uuid](https://pub.dev/packages/sane_uuid) 1.0.0 was released, which has a few minor breaking change as compared to to 1.0.0-rc.5 that impact realm: + - The `Uuid.fromBytes` factory now accepts a `Uint8List` instead of a `ByteBuffer` + - The type of `Uuid.bytes` has changed to `Uint8List`. + + Issue [#1729](https://github.com/realm/realm-dart/issues/1729) ### Compatibility * Realm Studio: 15.0.0 or later. diff --git a/packages/ejson/lib/src/decoding.dart b/packages/ejson/lib/src/decoding.dart index d0c369c9d..f91549abb 100644 --- a/packages/ejson/lib/src/decoding.dart +++ b/packages/ejson/lib/src/decoding.dart @@ -243,7 +243,7 @@ UndefinedOr _decodeUndefinedOr(EJsonValue ejson) { Uuid _decodeUuid(EJsonValue ejson) { return switch (ejson) { - {'\$binary': {'base64': String s, 'subType': '04'}} => Uuid.fromBytes(base64.decode(s).buffer), + {'\$binary': {'base64': String s, 'subType': '04'}} => Uuid.fromBytes(base64.decode(s)), _ => raiseInvalidEJson(ejson), }; } diff --git a/packages/ejson/lib/src/encoding.dart b/packages/ejson/lib/src/encoding.dart index fd58b398a..cfe11b15d 100644 --- a/packages/ejson/lib/src/encoding.dart +++ b/packages/ejson/lib/src/encoding.dart @@ -117,7 +117,7 @@ EJsonValue _encodeSymbol(Symbol value) => {'\$symbol': value.name}; EJsonValue _encodeUndefined(Undefined undefined) => {'\$undefined': 1}; -EJsonValue _encodeUuid(Uuid uuid) => _encodeBinary(uuid.bytes.asUint8List(), subtype: '04'); +EJsonValue _encodeUuid(Uuid uuid) => _encodeBinary(uuid.bytes, subtype: '04'); EJsonValue _encodeBinary(Uint8List buffer, {required String subtype}) => { '\$binary': { diff --git a/packages/ejson/pubspec.yaml b/packages/ejson/pubspec.yaml index 02b1a68be..e17ff6f92 100644 --- a/packages/ejson/pubspec.yaml +++ b/packages/ejson/pubspec.yaml @@ -22,7 +22,7 @@ dependencies: collection: ^1.17.0 ejson_annotation: ^0.3.0 objectid: ^3.0.0 - sane_uuid: ^1.0.0-alpha.5 + sane_uuid: ^1.0.0 type_plus: ^2.0.0 dev_dependencies: diff --git a/packages/ejson/test/ejson_test.dart b/packages/ejson/test/ejson_test.dart index 7b117b736..04e1e96d7 100644 --- a/packages/ejson/test/ejson_test.dart +++ b/packages/ejson/test/ejson_test.dart @@ -93,7 +93,7 @@ void main() { expect(ObjectId.fromValues(1, 2, 3).toEJson(), toEJson(ObjectId.fromValues(1, 2, 3))); final uuid = Uuid.v4(); expect(uuid.toEJson(), toEJson(uuid)); - final bytes = uuid.bytes.asUint8List(); + final bytes = uuid.bytes; expect(bytes.toEJson(), toEJson(bytes)); }); @@ -200,7 +200,7 @@ void main() { _testCase(ObjectId.fromValues(1, 2, 3), {'\$oid': '000000000000000002000003'}); final uuid = Uuid.v4(); _testCase(uuid, { - '\$binary': {'base64': base64.encode(uuid.bytes.asUint8List()), 'subType': '04'} + '\$binary': {'base64': base64.encode(uuid.bytes), 'subType': '04'} }); final uint8list = Uint8List.fromList(List.generate(32, (i) => i)); _testCase(uint8list, { diff --git a/packages/realm_common/pubspec.yaml b/packages/realm_common/pubspec.yaml index e97f238ed..3b6ed7b8a 100644 --- a/packages/realm_common/pubspec.yaml +++ b/packages/realm_common/pubspec.yaml @@ -15,7 +15,7 @@ environment: dependencies: collection: ^1.18.0 objectid: ^3.0.0 - sane_uuid: ^1.0.0-alpha.5 + sane_uuid: ^1.0.0 dev_dependencies: lints: ^3.0.0 diff --git a/packages/realm_dart/lib/src/handles/native/from_native.dart b/packages/realm_dart/lib/src/handles/native/from_native.dart index 609782e36..f61812228 100644 --- a/packages/realm_dart/lib/src/handles/native/from_native.dart +++ b/packages/realm_dart/lib/src/handles/native/from_native.dart @@ -59,7 +59,7 @@ extension RealmValueEx on realm_value_t { return ObjectId.fromBytes(values.object_id.bytes.toList(12)); case realm_value_type.RLM_TYPE_UUID: final listInt = values.uuid.bytes.toList(16); - return Uuid.fromBytes(Uint8List.fromList(listInt).buffer); + return Uuid.fromBytes(Uint8List.fromList(listInt)); case realm_value_type.RLM_TYPE_LIST: if (getList == null || realm == null) { throw RealmException('toDartValue called with a list argument but without a list getter'); diff --git a/packages/realm_dart/lib/src/handles/native/to_native.dart b/packages/realm_dart/lib/src/handles/native/to_native.dart index 476a5fbe5..9eb3abdd5 100644 --- a/packages/realm_dart/lib/src/handles/native/to_native.dart +++ b/packages/realm_dart/lib/src/handles/native/to_native.dart @@ -136,7 +136,7 @@ void _intoRealmValue(Object? value, realm_value realmValue, Allocator allocator) } realmValue.type = realm_value_type.RLM_TYPE_OBJECT_ID; } else if (value is Uuid) { - final bytes = value.bytes.asUint8List(); + final bytes = value.bytes; for (var i = 0; i < 16; i++) { realmValue.values.uuid.bytes[i] = bytes[i]; } diff --git a/packages/realm_dart/test/indexed_test.dart b/packages/realm_dart/test/indexed_test.dart index 7c64e85b8..242c6b9ee 100644 --- a/packages/realm_dart/test/indexed_test.dart +++ b/packages/realm_dart/test/indexed_test.dart @@ -78,7 +78,7 @@ void main() { stringFactory(int i) => '${i.hashCode} $i'; timestampFactory(int i) => DateTime.fromMillisecondsSinceEpoch(i.hashCode); objectIdFactory(int i) => ObjectId.fromValues(i.hashCode * 1000000, i.hashCode, i); - uuidFactory(int i) => Uuid.fromBytes(Uint8List(16).buffer..asByteData().setInt64(0, i.hashCode)); + uuidFactory(int i) => Uuid.fromBytes(Uint8List(16)..buffer.asByteData().setInt64(0, i.hashCode)); // skip timestamp for now, as timestamps are not indexed properly it seems final indexedTestData = [