diff --git a/drift/lib/src/remote/protocol.dart b/drift/lib/src/remote/protocol.dart index 76d17141..3ff69a1b 100644 --- a/drift/lib/src/remote/protocol.dart +++ b/drift/lib/src/remote/protocol.dart @@ -253,8 +253,8 @@ class DriftProtocol { } Object? _decodeDbValue(Object? wire) { - if (wire is List) { - return wire.cast(); + if (wire is List && wire is! Uint8List) { + return Uint8List.fromList(wire.cast()); } else { return wire; } diff --git a/drift/test/remote_test.dart b/drift/test/remote_test.dart index 5fd9d36e..084c7a14 100644 --- a/drift/test/remote_test.dart +++ b/drift/test/remote_test.dart @@ -1,5 +1,7 @@ import 'package:async/async.dart'; +import 'package:drift/drift.dart'; import 'package:drift/remote.dart'; +import 'package:drift/src/remote/protocol.dart'; import 'package:stream_channel/stream_channel.dart'; import 'package:test/test.dart'; @@ -20,4 +22,27 @@ void main() { await shutdown(transformed); }); + + test('Uint8Lists are mapped from and to Uint8Lists', () async { + const protocol = DriftProtocol(); + + final request = Request( + 1, + ExecuteQuery(StatementMethod.select, 'SELECT ?', [ + Uint8List.fromList([1, 2, 3]) + ]), + ); + + final mapped = protocol.deserialize(protocol.serialize(request)!); + expect( + mapped, + isA().having((e) => e.id, 'id', 1).having( + (e) => e.payload, + 'payload', + isA() + .having((e) => e.method, 'method', StatementMethod.select) + .having((e) => e.args, 'args', [isA()]), + ), + ); + }); }