Replies: 4 comments 15 replies
-
Can totally agree with the transactions lifetime issue point. Would it maybe be possible to provide an api like: let tx = connection.begin().await?;
....execute(&mut tx).await?;
drop(tx); |
Beta Was this translation helpful? Give feedback.
-
Thanks for reporting back those experience. Let me try to address a few of those points:
I would prefer to "require" something like use diesel::prelude::*;
use diesel_async::{RunQueryDsl, AsyncPgConnection}; (Note that named imports always "overwrite" wildcard imports, so rustc will use
I'm not sure I can really follow here. Can you provide an example for this. I would assume that the transaction callbacks work similar than in "normal" diesel, at least in terms of using the connection.
As this is the first release of diesel-async at all, there are no final numbers on that yet. From the benchmarks over at the main diesel repository it looks like
I'm opposed to such an API as it makes it much harder to somehow handle the case where users forget to explicitly |
Beta Was this translation helpful? Give feedback.
-
In fact, i'm facing an issue since a couple of days, which seems only to have a solution using a low-level API to access the transaction_manager directly.
So back to the UnitOfWork. I've implemented it, pretty much the same way the run method is defined today. You call
Both save operations are handled transactionally without any reference to an ORM framework and the connection is managed by RepositoryFactory and passed around to created Repository instances when calling get_repository(). |
Beta Was this translation helpful? Give feedback.
-
Wanted to add that the initial post has pretty much mirrored my experience trying to port existing diesel code. I think there's at least some headaches coming from the compiler's lack of async lifetime support, some from the rough ergonomics around forced use of boxing and
|
Beta Was this translation helpful? Give feedback.
-
Hi,
Thanks for your work on diesel.
I wrote some notes on stuff I came across when moving from diesel 2.0.0 to diesel-async 0.1.0 in a small (~6000 LOC) private codebase.
use diesel::prelude::*
with the exception ofuse diesel::result::Error as DieselError;
in an error module. I think it'd be nice to have an equivalent in diesel-async that is similar to diesel's prelude but replaces/adds the relevant traits and types from diesel-async. Maybe even includeFutureExt
forboxed
.That was a little awkward as well, as previously I just took(edit: This turned out to not be an issue, I just mixed something up while debugging other problems) I guess the long term solution is to wait for async scopes...&mut PgConnection
, which worked with both pooled and unpooled connections (used mostly in tests) thanks to someDeref
impl, but the naive owned version now takesObject<AsyncPgConnection>
which always requires the connection to be pooled. I could make the functions generic but I'm not sure that'd be worth the trouble.Pool
andObject
type aliases including theAsyncDieselConnectionManager
, mainly because the equivalent diesel type aliases don't do it. Not a big deal either way, just something I noticed.tokio::task::spawn_blocking
. Any idea? If not or just a vague one, that's fine too.Beta Was this translation helpful? Give feedback.
All reactions