Convert integer to binary PostgreSQL format
(&self, value: i64, pg_type_oid: i32)
| 257 | |
| 258 | /// Convert integer to binary PostgreSQL format |
| 259 | fn convert_integer_binary(&self, value: i64, pg_type_oid: i32) -> Vec<u8> { |
| 260 | use crate::protocol::BinaryEncoder; |
| 261 | |
| 262 | match pg_type_oid { |
| 263 | t if t == PgType::Int2.to_oid() => BinaryEncoder::encode_int2(value as i16), // INT2 |
| 264 | t if t == PgType::Int4.to_oid() => BinaryEncoder::encode_int4(value as i32), // INT4 |
| 265 | t if t == PgType::Int8.to_oid() => BinaryEncoder::encode_int8(value), // INT8 |
| 266 | t if t == PgType::Bool.to_oid() => BinaryEncoder::encode_bool(value != 0), // BOOL |
| 267 | _ => value.to_string().into_bytes(), // Fallback to text |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | /// Convert real to binary PostgreSQL format |
| 272 | fn convert_real_binary(&self, value: f64, pg_type_oid: i32) -> Vec<u8> { |
no test coverage detected