Skip to content

Commit ebcd65b

Browse files
committed
match spec data size
1 parent e3ca8c8 commit ebcd65b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/src/binary_codec.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,9 @@ class PostgresBinaryEncoder extends Converter<dynamic, Uint8List?> {
151151
case PostgreSQLDataType.interval:
152152
{
153153
if (value is Duration) {
154-
final bd = ByteData(8);
154+
final bd = ByteData(16);
155155
bd.setInt64(0, value.inMicroseconds);
156+
// ignoring the second 8 bytes
156157
return bd.buffer.asUint8List();
157158
}
158159
throw FormatException(
@@ -434,6 +435,7 @@ class PostgresBinaryDecoder extends Converter<Uint8List, dynamic> {
434435
.add(Duration(microseconds: buffer.getInt64(0)));
435436

436437
case PostgreSQLDataType.interval:
438+
if (buffer.getInt64(8) != 0) throw UnimplementedError();
437439
return Duration(microseconds: buffer.getInt64(0));
438440

439441
case PostgreSQLDataType.numeric:

0 commit comments

Comments
 (0)