diesel/sqlite/mod.rs
1//! Provides types and functions related to working with SQLite
2//!
3//! Much of this module is re-exported from database agnostic locations.
4//! However, if you are writing code specifically to extend Diesel on
5//! SQLite, you may need to work with this module directly.
6
7pub(crate) mod backend;
8mod connection;
9pub mod expression;
10
11pub mod query_builder;
12
13mod types;
14
15pub use self::backend::{Sqlite, SqliteType};
16pub use self::connection::SerializedDatabase;
17pub use self::connection::SqliteBindValue;
18pub use self::connection::SqliteConnection;
19pub use self::connection::SqliteValue;
20pub use self::connection::sqlite_blob::SqliteReadOnlyBlob;
21pub use self::query_builder::SqliteQueryBuilder;
22
23/// Trait for the implementation of a SQLite aggregate function
24///
25/// This trait is to be used in conjunction with the `define_sql_function!`
26/// macro for defining a custom SQLite aggregate function. See
27/// the documentation [there](super::prelude::define_sql_function!) for details.
28pub trait SqliteAggregateFunction<Args>: Default {
29 /// The result type of the SQLite aggregate function
30 type Output;
31
32 /// The `step()` method is called once for every record of the query.
33 ///
34 /// This is called through a C FFI, as such panics do not propagate to the caller. Panics are
35 /// caught and cause a return with an error value. The implementation must still ensure that
36 /// state remains in a valid state (refer to [`std::panic::UnwindSafe`] for a bit more detail).
37 fn step(&mut self, args: Args);
38
39 /// After the last row has been processed, the `finalize()` method is
40 /// called to compute the result of the aggregate function. If no rows
41 /// were processed `aggregator` will be `None` and `finalize()` can be
42 /// used to specify a default result.
43 ///
44 /// This is called through a C FFI, as such panics do not propagate to the caller. Panics are
45 /// caught and cause a return with an error value.
46 fn finalize(aggregator: Option<Self>) -> Self::Output;
47}
48
49/// SQLite specific sql types
50pub mod sql_types {
51 #[doc(inline)]
52 pub use super::types::Timestamptz;
53
54 #[cfg(feature = "__sqlite-shared")]
55 #[doc(inline)]
56 pub use super::types::JsonValidFlags;
57}
58
59#[cfg(feature = "__sqlite-shared")]
60pub use self::types::JsonValidFlag;