Closed
Description
I was reading the docs on https://www.postgresql.org/docs/current/sql-notify.html.
I'm glad that this library listens well to NOTIFY channel_name 'Payload'
notifications.
It however fails on SELECT pg_notify('VIRTUAL','Payload 2');
import 'package:postgres/postgres_v3_experimental.dart';
import 'package:test/test.dart';
import 'package:dotenv/dotenv.dart';
void main() {
late PgConnection connection;
setUpAll(() async {
final endpoint = PgEndpoint(host: 'localhost', database: 'postgres');
connection = await PgConnection.open(endpoint);
});
test('can listen to virtual channel', () async {
await connection.execute('LISTEN VIRTUAL;');
final channel = connection.channels['virtual'].asBroadcastStream();
channel.listen((event) {
print(event);
});
print(channel);
var count = 1;
channel.listen(
expectAsync1(
(event) {
if (count == 1) {
expect(event, equals('Payload'));
} else if (count == 2) {
expect(event, equals('Payload 2'));
}
count++;
},
count: 2,
),
);
final result = await connection.execute(
PgSql('''NOTIFY VIRTUAL, 'Payload';'''),
);
///UnimplementedError: Text decoding for PgDataType.byteArray
/// PostgresTextDecoder.convert
/// text_codec.dart:247
/// dart:convert Codec.decode
await connection.execute(
// PgSql('''NOTIFY VIRTUAL, 'Payload 2';'''),
PgSql('''SELECT pg_notify('VIRTUAL','Payload 2');'''),
);
print(result);
});
}
This prints
Payload
UnimplementedError: Text decoding for PgDataType.byteArray
PostgresTextDecoder.convert
text_codec.dart:247
dart:convert Codec.decode
_PgResultStreamSubscription.handleMessage
connection.dart:453
PgConnectionImplementation._handleMessage
connection.dart:220
How does one convert from byteArray to say a String that was the message sent by pg_notify?
@simolus3 any pointers?. Thanks in advance.
Metadata
Metadata
Assignees
Labels
No labels