836 has been helpful as a way of pairing parameter types with their encodings, but the encode_format method in the ToSql trait would be even more useful with the addition of a reference to Type. This would enable more granular encoding of parameters based on the types inferred by Postgres during the prepare phase, which would be useful when processing payloads from more general type systems like gRPC or JSON.
Since parameter types are already generated by the time bind() is called, it's easy to include them as part of the format-generating process. This PR simply adds a Type parameter to the encode_format method added to ToSql, which should not be a breaking change if it can be made before the next release.
836 has been helpful as a way of pairing parameter types with their encodings, but the
encode_format
method in theToSql
trait would be even more useful with the addition of a reference toType
. This would enable more granular encoding of parameters based on the types inferred by Postgres during theprepare
phase, which would be useful when processing payloads from more general type systems like gRPC or JSON.Since parameter types are already generated by the time
bind()
is called, it's easy to include them as part of the format-generating process. This PR simply adds aType
parameter to theencode_format
method added toToSql
, which should not be a breaking change if it can be made before the next release.