Skip to content

Commit

Permalink
addapt for diesel2
Browse files Browse the repository at this point in the history
  • Loading branch information
zorancv committed Feb 5, 2024
1 parent 3293abb commit 126b579
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
9 changes: 3 additions & 6 deletions graph/src/blockchain/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ use anyhow::anyhow;
use chrono::{DateTime, Utc};
use diesel::deserialize::FromSql;
use diesel::pg::Pg;
use diesel::serialize::Output;
use diesel::serialize::{Output, ToSql};
use diesel::sql_types::Timestamptz;
use diesel::sql_types::{Bytea, Nullable, Text};
use diesel::types::FromSql;
use diesel::types::ToSql;
use diesel_derives::{AsExpression, FromSqlRow};
use diesel_derives::FromSqlRow;
use std::convert::TryFrom;
use std::io::Write;
use std::time::Duration;
use std::{fmt, str::FromStr};
use web3::types::{Block, H256};
Expand Down Expand Up @@ -391,7 +388,7 @@ impl TryFrom<&Value> for BlockTime {
}

impl ToSql<Timestamptz, Pg> for BlockTime {
fn to_sql<W: Write>(&self, out: &mut Output<W, Pg>) -> diesel::serialize::Result {
fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> diesel::serialize::Result {
<DateTime<Utc> as ToSql<Timestamptz, Pg>>::to_sql(&self.0, out)
}
}
6 changes: 3 additions & 3 deletions store/postgres/src/deployment_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -919,9 +919,9 @@ impl DeploymentStore {
) -> Result<Option<BlockTime>, StoreError> {
let store = self.cheap_clone();

let conn = self.get_conn()?;
let layout = store.layout(&conn, site.cheap_clone())?;
layout.block_time(&conn, block)
let mut conn = self.get_conn()?;
let layout = store.layout(&mut conn, site.cheap_clone())?;
layout.block_time(&mut conn, block)
}

pub(crate) async fn supports_proof_of_indexing<'a>(
Expand Down
4 changes: 2 additions & 2 deletions store/postgres/src/relational.rs
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ impl Layout {

pub(crate) fn block_time(
&self,
conn: &PgConnection,
conn: &mut PgConnection,
block: BlockNumber,
) -> Result<Option<BlockTime>, StoreError> {
let block_time_name = self.input_schema.poi_block_time();
Expand Down Expand Up @@ -1017,7 +1017,7 @@ impl Layout {
/// numbers and block times which we do not have anywhere in graph-node.
pub(crate) fn rollup(
&self,
conn: &PgConnection,
conn: &mut PgConnection,
last_rollup: Option<BlockTime>,
block_times: &[(BlockNumber, BlockTime)],
) -> Result<(), StoreError> {
Expand Down
2 changes: 1 addition & 1 deletion store/postgres/src/relational/rollup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl Rollup {

pub(crate) fn insert(
&self,
conn: &PgConnection,
conn: &mut PgConnection,
bucket: &Range<BlockTime>,
block: BlockNumber,
) -> Result<usize, diesel::result::Error> {
Expand Down

0 comments on commit 126b579

Please sign in to comment.