Skip to content

Commit d1e736e

Browse files
authored
bump: to 1.0.0-beta.2 (#17)
1 parent 483e30e commit d1e736e

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "apalis-sqlite"
3-
version = "1.0.0-beta.1"
3+
version = "1.0.0-beta.2"
44
authors = ["Njuguna Mureithi <[email protected]>"]
55
readme = "README.md"
66
edition = "2024"

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use futures::{
2222
};
2323
pub use sqlx::{
2424
Connection, Pool, Sqlite, SqliteConnection, SqlitePool,
25+
error::Error as SqlxError,
2526
pool::{PoolConnection, PoolOptions},
2627
sqlite::{SqliteConnectOptions, SqliteOperation},
2728
};

src/queries/fetch_by_id.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ where
2929
let row: TaskRow = r
3030
.try_into()
3131
.map_err(|e: sqlx::Error| FromRowError::DecodeError(e.into()))?;
32-
row.try_into_task::<D, _, Ulid>()
32+
row.try_into_task_compact().and_then(|t| {
33+
t.try_map(|a| {
34+
D::decode(&a).map_err(|e| FromRowError::DecodeError(e.into()))
35+
})
36+
})
3337
})
3438
.transpose()
3539
.map_err(|e| sqlx::Error::Protocol(e.to_string()))?;

src/queries/list_tasks.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use apalis_core::{
22
backend::{BackendExt, Filter, ListAllTasks, ListTasks, codec::Codec},
33
task::{Task, status::Status},
44
};
5-
use apalis_sql::from_row::TaskRow;
5+
use apalis_sql::from_row::{FromRowError, TaskRow};
66
use ulid::Ulid;
77

88
use crate::{CompactType, SqlContext, SqliteStorage, SqliteTask, from_row::SqliteTaskRow};
@@ -42,11 +42,15 @@ where
4242
.await?
4343
.into_iter()
4444
.map(|r| {
45-
let row: TaskRow = r.try_into()?;
46-
row.try_into_task::<D, _, Ulid>()
47-
.map_err(|e| sqlx::Error::Protocol(e.to_string()))
45+
let row: TaskRow = r
46+
.try_into()
47+
.map_err(|e: sqlx::Error| FromRowError::DecodeError(e.into()))?;
48+
row.try_into_task_compact().and_then(|t| {
49+
t.try_map(|a| D::decode(&a).map_err(|e| FromRowError::DecodeError(e.into())))
50+
})
4851
})
49-
.collect::<Result<Vec<_>, _>>()?;
52+
.collect::<Result<Vec<_>, _>>()
53+
.map_err(|e| sqlx::Error::Decode(e.into()))?;
5054
Ok(tasks)
5155
}
5256
}

0 commit comments

Comments
 (0)