pub fn null_datum(ty: &Type) -> (Datum<'static>, ScalarType) {
    let ty = match ty {
        Type::Array(t) => {
            let (_, elem_type) = null_datum(t);
            ScalarType::Array(Box::new(elem_type))
        }
        Type::Bool => ScalarType::Bool,
        Type::Bytea => ScalarType::Bytes,
        Type::Date => ScalarType::Date,
        Type::Float4 => ScalarType::Float32,
        Type::Float8 => ScalarType::Float64,
        Type::Int2 => ScalarType::Int16,
        Type::Int4 => ScalarType::Int32,
        Type::Int8 => ScalarType::Int64,
        Type::Interval => ScalarType::Interval,
        Type::Jsonb => ScalarType::Jsonb,
        Type::List(t) => {
            let (_, elem_type) = null_datum(t);
            ScalarType::List {
                element_type: Box::new(elem_type),
                custom_oid: None,
            }
        }
        Type::Numeric => ScalarType::Numeric { scale: None },
        Type::Oid => ScalarType::Oid,
        Type::Text => ScalarType::String,
        Type::Char => ScalarType::Char { length: None },
        Type::VarChar => ScalarType::VarChar { length: None },
        Type::Time => ScalarType::Time,
        Type::Timestamp => ScalarType::Timestamp,
        Type::TimestampTz => ScalarType::TimestampTz,
        Type::Uuid => ScalarType::Uuid,
        Type::Record(fields) => {
            let fields = fields
                .iter()
                .enumerate()
                .map(|(i, ty)| {
                    let name = ColumnName::from(format!("f{}", i + 1));
                    (
                        name,
                        ColumnType {
                            nullable: true,
                            scalar_type: null_datum(ty).1,
                        },
                    )
                })
                .collect();
            ScalarType::Record {
                fields,
                custom_oid: None,
                custom_name: None,
            }
        }
        Type::Map { value_type } => {
            let (_, value_type) = null_datum(value_type);
            ScalarType::Map {
                value_type: Box::new(value_type),
                custom_oid: None,
            }
        }
        Type::RegClass => ScalarType::RegClass,
        Type::RegProc => ScalarType::RegProc,
        Type::RegType => ScalarType::RegType,
    };
    (Datum::Null, ty)
}
/// Constructs a null datum of the specified type.
Constructs a null datum of the specified type.
Constructs a null datum of the specified type .
pub fn null_datum(ty: &Type) -> (Datum<'static>, ScalarType) {
    let ty = match ty {
        Type::Array(t) => {
            let (_, elem_type) = null_datum(t);
            ScalarType::Array(Box::new(elem_type))
        }
        Type::Bool => ScalarType::Bool,
        Type::Bytea => ScalarType::Bytes,
        Type::Date => ScalarType::Date,
        Type::Float4 => ScalarType::Float32,
        Type::Float8 => ScalarType::Float64,
        Type::Int2 => ScalarType::Int16,
        Type::Int4 => ScalarType::Int32,
        Type::Int8 => ScalarType::Int64,
        Type::Interval => ScalarType::Interval,
        Type::Jsonb => ScalarType::Jsonb,
        Type::List(t) => {
            let (_, elem_type) = null_datum(t);
            ScalarType::List {
                element_type: Box::new(elem_type),
                custom_oid: None,
            }
        }
        Type::Numeric => ScalarType::Numeric { scale: None },
        Type::Oid => ScalarType::Oid,
        Type::Text => ScalarType::String,
        Type::Char => ScalarType::Char { length: None },
        Type::VarChar => ScalarType::VarChar { length: None },
        Type::Time => ScalarType::Time,
        Type::Timestamp => ScalarType::Timestamp,
        Type::TimestampTz => ScalarType::TimestampTz,
        Type::Uuid => ScalarType::Uuid,
        Type::Record(fields) => {
            let fields = fields
                .iter()
                .enumerate()
                .map(|(i, ty)| {
                    let name = ColumnName::from(format!("f{}", i + 1));
                    (
                        name,
                        ColumnType {
                            nullable: true,
                            scalar_type: null_datum(ty).1,
                        },
                    )
                })
                .collect();
            ScalarType::Record {
                fields,
                custom_oid: None,
                custom_name: None,
            }
        }
        Type::Map { value_type } => {
            let (_, value_type) = null_datum(value_type);
            ScalarType::Map {
                value_type: Box::new(value_type),
                custom_oid: None,
            }
        }
        Type::RegClass => ScalarType::RegClass,
        Type::RegProc => ScalarType::RegProc,
        Type::RegType => ScalarType::RegType,
    };
    (Datum::Null, ty)
}
pub fn null_datum ( ty : & Type ) -> ( Datum < ' static > , ScalarType ) { let ty = match ty { Type :: Array ( t ) => { let ( _ , elem_type ) = null_datum ( t ) ; ScalarType :: Array ( Box :: new ( elem_type ) ) } Type :: Bool => ScalarType :: Bool , Type :: Bytea => ScalarType :: Bytes , Type :: Date => ScalarType :: Date , Type :: Float4 => ScalarType :: Float32 , Type :: Float8 => ScalarType :: Float64 , Type :: Int2 => ScalarType :: Int16 , Type :: Int4 => ScalarType :: Int32 , Type :: Int8 => ScalarType :: Int64 , Type :: Interval => ScalarType :: Interval , Type :: Jsonb => ScalarType :: Jsonb , Type :: List ( t ) => { let ( _ , elem_type ) = null_datum ( t ) ; ScalarType :: List { element_type : Box :: new ( elem_type ) , custom_oid : None , } } Type :: Numeric => ScalarType :: Numeric { scale : None } , Type :: Oid => ScalarType :: Oid , Type :: Text => ScalarType :: String , Type :: Char => ScalarType :: Char { length : None } , Type :: VarChar => ScalarType :: VarChar { length : None } , Type :: Time => ScalarType :: Time , Type :: Timestamp => ScalarType :: Timestamp , Type :: TimestampTz => ScalarType :: TimestampTz , Type :: Uuid => ScalarType :: Uuid , Type :: Record ( fields ) => { let fields = fields . iter ( ) . enumerate ( ) . map ( | ( i , ty ) | { let name = ColumnName :: from ( format ! ( " " i 1 ) ) ; ( name , ColumnType { nullable : true , scalar_type : null_datum ( ty ) . 1 , } , ) } ) . collect ( ) ; ScalarType :: Record { fields , custom_oid : None , custom_name : None , } } Type :: Map { value_type } => { let ( _ , value_type ) = null_datum ( value_type ) ; ScalarType :: Map { value_type : Box :: new ( value_type ) , custom_oid : None , } } Type :: RegClass => ScalarType :: RegClass , Type :: RegProc => ScalarType :: RegProc , Type :: RegType => ScalarType :: RegType , } ; ( Datum :: Null , ty ) }
Constructs a null datum of the specified type.
Constructs a null datum of the specified type .
ty
&Type
ty
&Type