private void AppendParameterValue(Stream dest, NpgsqlParameter parameter)
{
byte[] serialised = parameter.TypeInfo.ConvertToBackend(parameter.Value, false, Connector.NativeToBackendTypeConverterOptions);
// Add parentheses wrapping parameter value before the type cast to avoid problems with Int16.MinValue, Int32.MinValue and Int64.MinValue
// See bug #1010543
// Check if this parenthesis can be collapsed with the previous one about the array support. This way, we could use
// only one pair of parentheses for the two purposes instead of two pairs.
dest
.WriteBytes((byte)ASCIIBytes.ParenLeft)
.WriteBytes((byte)ASCIIBytes.ParenLeft)
.WriteBytes(serialised)
.WriteBytes((byte)ASCIIBytes.ParenRight);
if (parameter.UseCast)
{
dest.WriteString("::{0}", parameter.TypeInfo.CastName);
if (parameter.TypeInfo.UseSize && (parameter.Size > 0))
{
dest.WriteString("({0})", parameter.Size);
}
}
dest.WriteBytes((byte)ASCIIBytes.ParenRight);
}