feat(mssql): fix a few bugs and implement Connection::describe

This commit is contained in:
Ryan Leckey
2020-06-07 01:59:59 -07:00
parent 559169cc79
commit ef2527ff3e
27 changed files with 424 additions and 61 deletions

View File

@@ -68,36 +68,49 @@ where
}
}
impl<'q, T: 'q + Encode<'q, DB>, DB: Database> Encode<'q, DB> for Option<T> {
#[inline]
fn produces(&self) -> DB::TypeInfo {
if let Some(v) = self {
v.produces()
} else {
T::type_info()
}
}
#[allow(unused_macros)]
macro_rules! impl_encode_for_option {
($DB:ident) => {
impl<'q, T: 'q + crate::encode::Encode<'q, $DB>> crate::encode::Encode<'q, $DB>
for Option<T>
{
#[inline]
fn produces(&self) -> <$DB as crate::database::Database>::TypeInfo {
if let Some(v) = self {
v.produces()
} else {
T::type_info()
}
}
#[inline]
fn encode(self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNull {
if let Some(v) = self {
v.encode(buf)
} else {
IsNull::Yes
}
}
#[inline]
fn encode(
self,
buf: &mut <$DB as crate::database::HasArguments<'q>>::ArgumentBuffer,
) -> crate::encode::IsNull {
if let Some(v) = self {
v.encode(buf)
} else {
crate::encode::IsNull::Yes
}
}
#[inline]
fn encode_by_ref(&self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNull {
if let Some(v) = self {
v.encode_by_ref(buf)
} else {
IsNull::Yes
}
}
#[inline]
fn encode_by_ref(
&self,
buf: &mut <$DB as crate::database::HasArguments<'q>>::ArgumentBuffer,
) -> crate::encode::IsNull {
if let Some(v) = self {
v.encode_by_ref(buf)
} else {
crate::encode::IsNull::Yes
}
}
#[inline]
fn size_hint(&self) -> usize {
self.as_ref().map_or(0, Encode::size_hint)
}
#[inline]
fn size_hint(&self) -> usize {
self.as_ref().map_or(0, crate::encode::Encode::size_hint)
}
}
};
}