|
@@ -160,21 +160,25 @@ impl PgConnection {
|
|
}
|
|
}
|
|
|
|
|
|
pub async fn tell_fortune(&self) -> Result<Vec<Fortune>, PgError> {
|
|
pub async fn tell_fortune(&self) -> Result<Vec<Fortune>, PgError> {
|
|
- let mut items = self
|
|
|
|
|
|
+ let mut items = vec![Fortune {
|
|
|
|
+ id: 0,
|
|
|
|
+ message: Cow::Borrowed("Additional fortune added at request time."),
|
|
|
|
+ }];
|
|
|
|
+
|
|
|
|
+ let stream = self
|
|
.client
|
|
.client
|
|
- .query(&self.fortune, &[])
|
|
|
|
- .await?
|
|
|
|
- .iter()
|
|
|
|
- .map(|row| Fortune {
|
|
|
|
|
|
+ .query_raw::<_, _, &[i32; 0]>(&self.fortune, &[])
|
|
|
|
+ .await?;
|
|
|
|
+ pin!(stream);
|
|
|
|
+
|
|
|
|
+ while let Some(row) = stream.next().await {
|
|
|
|
+ let row = row?;
|
|
|
|
+
|
|
|
|
+ items.push(Fortune {
|
|
id: row.get(0),
|
|
id: row.get(0),
|
|
message: Cow::Owned(row.get(1)),
|
|
message: Cow::Owned(row.get(1)),
|
|
- })
|
|
|
|
- .collect::<Vec<_>>();
|
|
|
|
-
|
|
|
|
- items.push(Fortune {
|
|
|
|
- id: 0,
|
|
|
|
- message: Cow::Borrowed("Additional fortune added at request time."),
|
|
|
|
- });
|
|
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
|
|
items.sort_by(|it, next| it.message.cmp(&next.message));
|
|
items.sort_by(|it, next| it.message.cmp(&next.message));
|
|
|
|
|