Merge pull request #995 from syrtcevvi/sqlx_advance

Sqlx version advance
This commit is contained in:
Waffle Maybe 2024-01-17 00:04:03 +00:00 committed by GitHub
commit 2945f4d301
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 15 additions and 15 deletions

View file

@ -55,6 +55,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- MSRV (Minimal Supported Rust Version) was bumped from `1.64.0` to `1.68.0` ([PR 950][https://github.com/teloxide/teloxide/pull/950]) - MSRV (Minimal Supported Rust Version) was bumped from `1.64.0` to `1.68.0` ([PR 950][https://github.com/teloxide/teloxide/pull/950])
- Sqlx version was bumped from `0.6` to `0.7.3`([PR 995](https://github.com/teloxide/teloxide/pull/995))
- Feature `sqlite-storage` was renamed to `sqlite-storage-nativetls`([PR 995](https://github.com/teloxide/teloxide/pull/995))
### Removed ### Removed

View file

@ -23,8 +23,7 @@ default = ["native-tls", "ctrlc_handler", "teloxide-core/default", "auto-send"]
webhooks = ["rand"] webhooks = ["rand"]
webhooks-axum = ["webhooks", "axum", "tower", "tower-http"] webhooks-axum = ["webhooks", "axum", "tower", "tower-http"]
# FIXME: rename `sqlite-storage` -> `sqlite-storage-nativetls` sqlite-storage-nativetls = ["sqlx", "sqlx/runtime-tokio-native-tls", "native-tls"]
sqlite-storage = ["sqlx", "sqlx/runtime-tokio-native-tls", "native-tls"]
sqlite-storage-rustls = ["sqlx", "sqlx/runtime-tokio-rustls", "rustls"] sqlite-storage-rustls = ["sqlx", "sqlx/runtime-tokio-rustls", "rustls"]
redis-storage = ["redis"] redis-storage = ["redis"]
cbor-serializer = ["serde_cbor"] cbor-serializer = ["serde_cbor"]
@ -51,9 +50,9 @@ nightly = ["teloxide-core/nightly"]
full = [ full = [
"webhooks", "webhooks",
"webhooks-axum", "webhooks-axum",
"sqlite-storage", "sqlite-storage-nativetls",
# "sqlite-storage-rustls" is explicitly ommited here, # "sqlite-storage-rustls" is explicitly ommited here,
# since it conflicts with "sqlite-storage" # since it conflicts with "sqlite-storage-nativetls"
"redis-storage", "redis-storage",
"cbor-serializer", "cbor-serializer",
"bincode-serializer", "bincode-serializer",
@ -99,7 +98,7 @@ serde_with_macros = "1.4"
aquamarine = "0.1.11" aquamarine = "0.1.11"
either = "1.9.0" either = "1.9.0"
sqlx = { version = "0.6", optional = true, default-features = false, features = [ sqlx = { version = "0.7.3", optional = true, default-features = false, features = [
"macros", "macros",
"sqlite", "sqlite",
] } ] }
@ -124,7 +123,7 @@ tokio-stream = "0.1"
[package.metadata.docs.rs] [package.metadata.docs.rs]
# NB: can't use `all-features = true`, because `sqlite-storage` conflicts with `sqlite-storage-rustls` # NB: can't use `all-features = true`, because `sqlite-storage-nativetls` conflicts with `sqlite-storage-rustls`
features = ["full", "nightly"] features = ["full", "nightly"]
# FIXME: Add back "-Znormalize-docs" when https://github.com/rust-lang/rust/issues/93703 is fixed # FIXME: Add back "-Znormalize-docs" when https://github.com/rust-lang/rust/issues/93703 is fixed
rustdoc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs"]
@ -147,7 +146,7 @@ required-features = ["redis-storage", "cbor-serializer", "bincode-serializer"]
[[test]] [[test]]
name = "sqlite" name = "sqlite"
path = "tests/sqlite.rs" path = "tests/sqlite.rs"
required-features = ["sqlite-storage", "cbor-serializer", "bincode-serializer"] required-features = ["sqlite-storage-nativetls", "cbor-serializer", "bincode-serializer"]
[[example]] [[example]]
@ -170,7 +169,7 @@ required-features = ["macros", "ctrlc_handler"]
[[example]] [[example]]
name = "db_remember" name = "db_remember"
required-features = [ required-features = [
"sqlite-storage", "sqlite-storage-nativetls",
"redis-storage", "redis-storage",
"bincode-serializer", "bincode-serializer",
"macros", "macros",

View file

@ -96,7 +96,7 @@
#[cfg(feature = "redis-storage")] #[cfg(feature = "redis-storage")]
pub use self::{RedisStorage, RedisStorageError}; pub use self::{RedisStorage, RedisStorageError};
#[cfg(feature = "sqlite-storage")] #[cfg(feature = "sqlite-storage-nativetls")]
pub use self::{SqliteStorage, SqliteStorageError}; pub use self::{SqliteStorage, SqliteStorageError};
pub use get_chat_id::GetChatId; pub use get_chat_id::GetChatId;

View file

@ -6,7 +6,7 @@ mod trace_storage;
#[cfg(feature = "redis-storage")] #[cfg(feature = "redis-storage")]
mod redis_storage; mod redis_storage;
#[cfg(feature = "sqlite-storage")] #[cfg(feature = "sqlite-storage-nativetls")]
mod sqlite_storage; mod sqlite_storage;
use futures::future::BoxFuture; use futures::future::BoxFuture;
@ -22,7 +22,7 @@ pub use redis_storage::{RedisStorage, RedisStorageError};
pub use serializer::Serializer; pub use serializer::Serializer;
use std::sync::Arc; use std::sync::Arc;
#[cfg(feature = "sqlite-storage")] #[cfg(feature = "sqlite-storage-nativetls")]
pub use sqlite_storage::{SqliteStorage, SqliteStorageError}; pub use sqlite_storage::{SqliteStorage, SqliteStorageError};
/// A storage with an erased error type. /// A storage with an erased error type.

View file

@ -40,7 +40,6 @@ impl<S> SqliteStorage<S> {
serializer: S, serializer: S,
) -> Result<Arc<Self>, SqliteStorageError<Infallible>> { ) -> Result<Arc<Self>, SqliteStorageError<Infallible>> {
let pool = SqlitePool::connect(format!("sqlite:{path}?mode=rwc").as_str()).await?; let pool = SqlitePool::connect(format!("sqlite:{path}?mode=rwc").as_str()).await?;
let mut conn = pool.acquire().await?;
sqlx::query( sqlx::query(
" "
CREATE TABLE IF NOT EXISTS teloxide_dialogues ( CREATE TABLE IF NOT EXISTS teloxide_dialogues (
@ -49,7 +48,7 @@ CREATE TABLE IF NOT EXISTS teloxide_dialogues (
); );
", ",
) )
.execute(&mut conn) .execute(&pool)
.await?; .await?;
Ok(Arc::new(Self { pool, serializer })) Ok(Arc::new(Self { pool, serializer }))

View file

@ -16,8 +16,8 @@
| `native-tls` | Enables the [`native-tls`] TLS implementation (**enabled by default**). | | `native-tls` | Enables the [`native-tls`] TLS implementation (**enabled by default**). |
| `rustls` | Enables the [`rustls`] TLS implementation. | | `rustls` | Enables the [`rustls`] TLS implementation. |
| `redis-storage` | Enables the [Redis] storage support for dialogues. | | `redis-storage` | Enables the [Redis] storage support for dialogues. |
| `sqlite-storage` | Enables the [Sqlite] storage support for dialogues (depends on `native-tls`). | | `sqlite-storage-nativetls` | Enables the [Sqlite] storage support for dialogues (depends on `native-tls`). |
| `sqlite-storage-rustls` | Enables the [Sqlite] storage support for dialogues (depends on `rustls`, conflicts with `sqlite-storage`). | | `sqlite-storage-rustls` | Enables the [Sqlite] storage support for dialogues (depends on `rustls`, conflicts with `sqlite-storage-nativetls`). |
| `cbor-serializer` | Enables the [CBOR] serializer for dialogues. | | `cbor-serializer` | Enables the [CBOR] serializer for dialogues. |
| `bincode-serializer` | Enables the [Bincode] serializer for dialogues. | | `bincode-serializer` | Enables the [Bincode] serializer for dialogues. |