mirror of
https://github.com/isar/rusqlite.git
synced 2025-08-20 21:09:31 +08:00
Doctest column name reference (#918)
* Doctest column name reference * Document rusqlite assumption on column name reference And move doctest as a test. * Document when columns metadata should be extracted. * Rustfmt doc (wrap_comments)
This commit is contained in:
@@ -15,9 +15,11 @@
|
||||
//! [`FromSql`] has different behaviour depending on the SQL and Rust types, and
|
||||
//! the value.
|
||||
//!
|
||||
//! * `INTEGER` to integer: returns an [`Error::IntegralValueOutOfRange`](crate::Error::IntegralValueOutOfRange) error if
|
||||
//! the value does not fit in the Rust type.
|
||||
//! * `REAL` to integer: always returns an [`Error::InvalidColumnType`](crate::Error::InvalidColumnType) error.
|
||||
//! * `INTEGER` to integer: returns an
|
||||
//! [`Error::IntegralValueOutOfRange`](crate::Error::IntegralValueOutOfRange)
|
||||
//! error if the value does not fit in the Rust type.
|
||||
//! * `REAL` to integer: always returns an
|
||||
//! [`Error::InvalidColumnType`](crate::Error::InvalidColumnType) error.
|
||||
//! * `INTEGER` to float: casts using `as` operator. Never fails.
|
||||
//! * `REAL` to float: casts using `as` operator. Never fails.
|
||||
//!
|
||||
@@ -62,8 +64,8 @@ impl ToSql for DateTimeSql {
|
||||
"##
|
||||
)]
|
||||
//! [`ToSql`] and [`FromSql`] are also implemented for `Option<T>` where `T`
|
||||
//! implements [`ToSql`] or [`FromSql`] for the cases where you want to know if a
|
||||
//! value was NULL (which gets translated to `None`).
|
||||
//! implements [`ToSql`] or [`FromSql`] for the cases where you want to know if
|
||||
//! a value was NULL (which gets translated to `None`).
|
||||
|
||||
pub use self::from_sql::{FromSql, FromSqlError, FromSqlResult};
|
||||
pub use self::to_sql::{ToSql, ToSqlOutput};
|
||||
|
@@ -3,7 +3,8 @@ use super::{Null, Type};
|
||||
/// Owning [dynamic type value](http://sqlite.org/datatype3.html). Value's type is typically
|
||||
/// dictated by SQLite (not by the caller).
|
||||
///
|
||||
/// See [`ValueRef`](crate::types::ValueRef) for a non-owning dynamic type value.
|
||||
/// See [`ValueRef`](crate::types::ValueRef) for a non-owning dynamic type
|
||||
/// value.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum Value {
|
||||
/// The value is a `NULL` value.
|
||||
|
@@ -35,7 +35,8 @@ impl ValueRef<'_> {
|
||||
|
||||
impl<'a> ValueRef<'a> {
|
||||
/// If `self` is case `Integer`, returns the integral value. Otherwise,
|
||||
/// returns [`Err(Error::InvalidColumnType)`](crate::Error::InvalidColumnType).
|
||||
/// returns [`Err(Error::InvalidColumnType)`](crate::Error::
|
||||
/// InvalidColumnType).
|
||||
#[inline]
|
||||
pub fn as_i64(&self) -> FromSqlResult<i64> {
|
||||
match *self {
|
||||
@@ -45,7 +46,8 @@ impl<'a> ValueRef<'a> {
|
||||
}
|
||||
|
||||
/// If `self` is case `Real`, returns the floating point value. Otherwise,
|
||||
/// returns [`Err(Error::InvalidColumnType)`](crate::Error::InvalidColumnType).
|
||||
/// returns [`Err(Error::InvalidColumnType)`](crate::Error::
|
||||
/// InvalidColumnType).
|
||||
#[inline]
|
||||
pub fn as_f64(&self) -> FromSqlResult<f64> {
|
||||
match *self {
|
||||
|
Reference in New Issue
Block a user