File tree Expand file tree Collapse file tree 4 files changed +46
-5
lines changed Expand file tree Collapse file tree 4 files changed +46
-5
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ sqlx_macros = ["sqlx/macros"]
2828# diesel features
2929diesel_postgres = [" diesel-async/postgres" , " diesel-async/deadpool" , " deadpool" , " diesel" ]
3030diesel_mysql = [" diesel-async/mysql" , " diesel-async/deadpool" , " deadpool" , " diesel" ]
31+ diesel_sqlite = [" diesel-async/sqlite" , " diesel-async/deadpool" , " deadpool" , " diesel" ]
3132# implicit features: mongodb
3233
3334[dependencies .rocket ]
Original file line number Diff line number Diff line change @@ -95,6 +95,10 @@ pub use diesel_async::AsyncMysqlConnection;
9595#[ cfg( feature = "diesel_postgres" ) ]
9696pub use diesel_async:: AsyncPgConnection ;
9797
98+ #[ doc( inline) ]
99+ #[ cfg( feature = "diesel_sqlite" ) ]
100+ pub use diesel_async:: sync_connection_wrapper:: SyncConnectionWrapper ;
101+
98102/// Alias of a `Result` with an error type of [`Debug`] for a `diesel::Error`.
99103///
100104/// `QueryResult` is a [`Responder`](rocket::response::Responder) when `T` (the
@@ -150,3 +154,25 @@ pub type MysqlPool = Pool<AsyncMysqlConnection>;
150154/// ```
151155#[ cfg( feature = "diesel_postgres" ) ]
152156pub type PgPool = Pool < AsyncPgConnection > ;
157+
158+ /// Type alias for an `async` pool of Sqlite connections for `async` [diesel].
159+ ///
160+ /// ```rust
161+ /// # extern crate rocket;
162+ /// # #[cfg(feature = "diesel_sqlite")] {
163+ /// # use rocket::get;
164+ /// use rocket_db_pools::{Database, Connection};
165+ /// use rocket_db_pools::diesel::{SqlitePool, prelude::*};
166+ ///
167+ /// #[derive(Database)]
168+ /// #[database("my_sqlite_db_name")]
169+ /// struct Db(SqlitePool);
170+ ///
171+ /// #[get("/")]
172+ /// async fn use_db(mut db: Connection<Db>) {
173+ /// /* .. */
174+ /// }
175+ /// # }
176+ /// ```
177+ #[ cfg( feature = "diesel_sqlite" ) ]
178+ pub type PgPool = Pool < SyncConnectionWrapper < SqliteConnection > > ;
Original file line number Diff line number Diff line change 141141//!
142142//! ## `diesel` (v2)
143143//!
144- //! | Database | Feature | [`Pool`] Type | [`Connection`] Deref |
145- //! |----------|-------------------|-----------------------|----------------------------------|
146- //! | Postgres | `diesel_postgres` | [`diesel::PgPool`] | [`diesel::AsyncPgConnection`] |
147- //! | MySQL | `diesel_mysql` | [`diesel::MysqlPool`] | [`diesel::AsyncMysqlConnection`] | //!
144+ //! | Database | Feature | [`Pool`] Type | [`Connection`] Deref |
145+ //! |----------|-------------------|------------------------|--------------------------------------------------------------|
146+ //! | Postgres | `diesel_postgres` | [`diesel::PgPool`] | [`diesel::AsyncPgConnection`] |
147+ //! | MySQL | `diesel_mysql` | [`diesel::MysqlPool`] | [`diesel::AsyncMysqlConnection`] |
148+ //! | SQLite | `diesel_sqlite` | [`diesel::SqlitePool`] | [`diesel::SyncConnectionWrapper<diesel::SqliteConnection>>`] |
148149//!
149150//! See [`diesel`] for usage details.
150151//!
@@ -243,7 +244,11 @@ pub use rocket;
243244#[ doc( inline) ]
244245pub use rocket:: figment;
245246
246- #[ cfg( any( feature = "diesel_postgres" , feature = "diesel_mysql" ) ) ] pub mod diesel;
247+ #[ cfg( any(
248+ feature = "diesel_postgres" ,
249+ feature = "diesel_mysql" ,
250+ feature = "diesel_sqlite"
251+ ) ) ] pub mod diesel;
247252#[ cfg( feature = "deadpool_postgres" ) ] pub use deadpool_postgres;
248253#[ cfg( feature = "deadpool_redis" ) ] pub use deadpool_redis;
249254#[ cfg( feature = "mongodb" ) ] pub use mongodb;
Original file line number Diff line number Diff line change @@ -192,6 +192,15 @@ mod deadpool_postgres {
192192 }
193193 }
194194
195+ #[ cfg( feature = "diesel_sqlite" ) ]
196+ impl DeadManager for AsyncDieselConnectionManager <
197+ diesel_async:: sync_connection_wrapper:: SyncConnectionWrapper :: < diesel:: SqliteConnection >
198+ > {
199+ fn new ( config : & Config ) -> Result < Self , Self :: Error > {
200+ Ok ( Self :: new ( config. url . as_str ( ) ) )
201+ }
202+ }
203+
195204 #[ rocket:: async_trait]
196205 impl < M : DeadManager , C : From < Object < M > > > crate :: Pool for Pool < M , C >
197206 where M :: Type : Send , C : Send + Sync + ' static , M :: Error : std:: error:: Error
You can’t perform that action at this time.
0 commit comments