use super::*;
impl<'a> Sql<'a> {
pub fn fragment(&self) -> SqlFragment<'_> {
SqlFragment::Lucky(self)
}
pub async fn execute(self, tx: &mut postgres::Client) -> Result<u64, postgres::error::Error> {
tx.execute(self.raw, self.bindings).await
}
pub async fn batch_execute(self, tx: &mut postgres::Client) -> Result<(), postgres::error::Error> {
tx.batch_execute(self.raw).await
}
pub async fn query(self, tx: &mut postgres::Client)-> Result<Vec<Row>, postgres::error::Error> {
tx.query(self.raw, self.bindings).await
}
pub async fn query_one(self, tx: &mut postgres::Client)-> Result<Row, postgres::error::Error> {
tx.query_one(self.raw, self.bindings).await
}
pub async fn query_into<T: FromSqlOwned>(self, tx: &mut postgres::Client)-> Result<T, postgres::error::Error> {
Ok(tx.query_one(self.raw, self.bindings).await?.get(0))
}
pub async fn query_opt(self, tx: &mut postgres::Client)-> Result<Option<Row>, postgres::error::Error> {
tx.query_opt(self.raw, self.bindings).await
}
}
impl<'a> GeneratedSql<'a> {
pub async fn execute(self, tx: &mut postgres::Client) -> Result<u64, postgres::error::Error> {
tx.execute(&self.raw, &self.bindings).await
}
pub async fn batch_execute(self, tx: &mut postgres::Client) -> Result<(), postgres::error::Error> {
tx.batch_execute(&self.raw).await
}
pub async fn query(self, tx: &mut postgres::Client)-> Result<Vec<Row>, postgres::error::Error> {
tx.query(&self.raw, &self.bindings).await
}
pub async fn query_one(self, tx: &mut postgres::Client)-> Result<Row, postgres::error::Error> {
tx.query_one(&self.raw, &self.bindings).await
}
pub async fn query_into<T: FromSqlOwned>(self, tx: &mut postgres::Client)-> Result<T, postgres::error::Error> {
Ok(tx.query_one(&self.raw, &self.bindings).await?.get(0))
}
pub async fn query_opt(self, tx: &mut postgres::Client)-> Result<Option<Row>, postgres::error::Error> {
tx.query_opt(&self.raw, &self.bindings).await
}
}