MCPcopy Create free account
hub / github.com/erans/pgsqlite / convert_integer_binary

Method convert_integer_binary

src/protocol/value_handler.rs:259–269  ·  view source on GitHub ↗

Convert integer to binary PostgreSQL format

(&self, value: i64, pg_type_oid: i32)

Source from the content-addressed store, hash-verified

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> {

Callers 1

handle_integer_valueMethod · 0.80

Calls 1

to_oidMethod · 0.80

Tested by

no test coverage detected