Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 3.5.10

- Supporting `BYTEA[]` built-in type.

## 3.5.9

- Supporting multiple hosts in connection strings via comma-separated hosts or multiple `host` query parameters.
Expand Down
7 changes: 7 additions & 0 deletions lib/src/types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,13 @@ abstract class Type<T extends Object> {
/// Each element of the list must fit into a byte (0-255).
static const byteArray = GenericType<List<int>>(TypeOid.byteArray);

/// Must be a [List<List<int>>].
///
/// Each inner list must be a valid bytea value.
static const byteArrayArray = GenericType<List<List<int>>>(
TypeOid.byteArrayArray,
);

/// Must be a [String]
///
/// Used for internal pg structure names
Expand Down
22 changes: 22 additions & 0 deletions lib/src/types/binary_codec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,22 @@ class PostgresBinaryEncoder {
);
}

case TypeOid.byteArrayArray:
{
if (input is List) {
return _writeListBytes<List<int>>(
_castOrThrowList<List<int>>(input),
TypeOid.byteArray,
(item) => item.length,
(writer, item) => writer.write(item),
encoding,
);
}
throw FormatException(
'Invalid type for parameter value. Expected: List<List<int>?> Got: ${input.runtimeType}',
);
}

case TypeOid.uuid:
{
if (input is! String) {
Expand Down Expand Up @@ -894,6 +910,12 @@ class PostgresBinaryDecoder {
case TypeOid.byteArray:
return input;

case TypeOid.byteArrayArray:
return readListBytes<Uint8List>(
input,
(reader, length) => reader.read(length),
);

case TypeOid.uuid:
return _decodeUuid(input);
case TypeOid.uuidArray:
Expand Down
4 changes: 4 additions & 0 deletions lib/src/types/type_registry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class TypeOid {
static const booleanArray = 1000;
static const box = 603;
static const byteArray = 17;
static const byteArrayArray = 1001;
static const character = 1042;
static const circle = 718;
static const date = 1082;
Expand Down Expand Up @@ -86,6 +87,7 @@ final _builtInTypes = <Type>{
Type.interval,
Type.numeric,
Type.byteArray,
Type.byteArrayArray,
Type.date,
Type.json,
Type.jsonb,
Expand Down Expand Up @@ -141,6 +143,7 @@ final _builtInCodecs = <int, Codec>{
TypeOid.interval: GenericCodec(TypeOid.interval),
TypeOid.numeric: GenericCodec(TypeOid.numeric),
TypeOid.byteArray: GenericCodec(TypeOid.byteArray),
TypeOid.byteArrayArray: GenericCodec(TypeOid.byteArrayArray),
TypeOid.date: GenericCodec(TypeOid.date),
TypeOid.json: GenericCodec(TypeOid.json, encodesNull: true),
TypeOid.jsonb: GenericCodec(TypeOid.jsonb, encodesNull: true),
Expand Down Expand Up @@ -180,6 +183,7 @@ final _builtInTypeNames = <String, Type>{
'bigint': Type.bigInteger,
'boolean': Type.boolean,
'bytea': Type.byteArray,
'_bytea': Type.byteArrayArray,
'bpchar': Type.character,
'char': Type.character,
'character': Type.character,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: postgres
description: PostgreSQL database driver. Supports binary protocol, connection pooling and statement reuse.
version: 3.5.9
version: 3.5.10
homepage: https://github.com/isoos/postgresql-dart
topics:
- sql
Expand Down
Loading