applyToBuffer method
Implementation
@override
void applyToBuffer(PgByteDataWriter buffer) {
final e = buffer.encodeString;
final properties = <_EncodedKeyPair>[
(e('client_encoding'), buffer.encodingName),
(e('database'), e(_databaseName)),
(e('TimeZone'), e(_timeZone)),
if (_username != null) (e('user'), e(_username!)),
if (_replication != ReplicationMode.none.value)
(e('replication'), e(_replication)),
if (_applicationName != null)
(e('application_name'), e(_applicationName!)),
];
final propertiesLength = properties
.map((e) => e.$1.bytesLength + e.$2.bytesLength + 2)
.fold<int>(0, (sum, x) => sum + x);
// 4 bytes length, 4 bytes protocol version, 1 extra zero at the end
buffer.writeInt32(propertiesLength + 4 + 4 + 1);
// protocol version
buffer.writeInt16(3);
buffer.writeInt16(0);
for (final e in properties) {
buffer.writeEncodedString(e.$1);
buffer.writeEncodedString(e.$2);
}
buffer.writeInt8(0);
}