PragmaTwice commented on code in PR #5208:
URL: https://github.com/apache/opendal/pull/5208#discussion_r1807737653
##########
core/src/services/sqlite/backend.rs:
##########
@@ -188,7 +195,27 @@ impl Adapter {
}
}
+#[self_referencing]
+pub struct SqlStream {
+ pool: SqlitePool,
+ query: String,
+
+ #[borrows(pool, query)]
+ #[covariant]
+ stream: BoxStream<'this, Result<String>>,
+}
Review Comment:
The lifetime handling here is a bit tricky.
`sqlx::query_scalar()` and its `.fetch()` heavily depend on lifetime
parameter restrictions:
```rust
pub fn fetch<'e, 'c: 'e, E>(self, executor: E) -> BoxStream<'e, Result<O,
Error>>
where
'q: 'e,
E: 'e + Executor<'c, Database = DB>,
DB: 'e,
A: 'e,
O: 'e,
```
So here to extend the lifetime (since we don't use GAT in our API here e.g.
`type ScanIter<'a>`, in order to be compatible to trait `List` which is also
not a GAT in `Access`.), we need to carry the `Pool` and also the query `&str`
and put it into a self-referencing structure and then we don't need to care the
lifetime checking.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]