sqlc-gen-sqlx 0.1.0

A sqlc plugin that generates type-safe sqlx Rust code from SQL queries.
Documentation
---
source: tests/codegen.rs
expression: code
---
// Code generated by sqlc-gen-sqlx v[VERSION]. DO NOT EDIT.
// sqlc version: [VERSION]

#![allow(dead_code, reason = "generated queries may expose items a caller does not use")]

#[derive(Debug, Clone)]
pub struct UpdateAuthorNamedParamsParams {
    pub set_name: String,
    pub author_id: i64,
}
const UPDATE_AUTHOR_NAMED_PARAMS: &str = "UPDATE authors SET name = $1 WHERE id = $2";
pub struct Queries<E> {
    db: E,
}
impl<E> Queries<E> {
    pub fn new(db: E) -> Self {
        Self { db }
    }
}
impl<E> Queries<E>
where
    for<'c> &'c mut E: sqlx::Executor<'c, Database = sqlx::Postgres>,
{
    pub async fn update_author_named_params(
        &mut self,
        arg: UpdateAuthorNamedParamsParams,
    ) -> Result<(), sqlx::Error> {
        sqlx::query(UPDATE_AUTHOR_NAMED_PARAMS)
            .bind(arg.set_name)
            .bind(arg.author_id)
            .execute(&mut self.db)
            .await?;
        Ok(())
    }
}