Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 12 additions & 36 deletions examples/advanced-types/src/queries.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Code generated by sqlc-gen-sqlx v0.1.0. DO NOT EDIT.
// Code generated by sqlc-gen-sqlx v0.1.1. DO NOT EDIT.
// sqlc version: v1.30.0

#![allow(
Expand All @@ -23,62 +23,35 @@ pub struct ListEventsRow {
pub event_window: sqlx::postgres::types::PgRange<chrono::DateTime<chrono::Utc>>,
}
pub trait AsExecutor {
type Exec<'c>: sqlx::Executor<'c, Database = sqlx::Postgres>
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_>;
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres>;
}
impl AsExecutor for sqlx::PgPool {
type Exec<'c>
= &'c sqlx::PgPool
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_> {
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> {
&*self
}
}
impl AsExecutor for &sqlx::PgPool {
type Exec<'c>
= &'c sqlx::PgPool
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_> {
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> {
*self
}
}
impl AsExecutor for sqlx::PgConnection {
type Exec<'c>
= &'c mut sqlx::PgConnection
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_> {
self
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> {
&mut *self
}
}
impl AsExecutor for sqlx::Transaction<'_, sqlx::Postgres> {
type Exec<'c>
= &'c mut sqlx::PgConnection
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_> {
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> {
&mut **self
}
}
impl AsExecutor for sqlx::pool::PoolConnection<sqlx::Postgres> {
type Exec<'c>
= &'c mut sqlx::PgConnection
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_> {
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> {
&mut **self
}
}
impl<T: AsExecutor + ?Sized> AsExecutor for &mut T {
type Exec<'c>
= T::Exec<'c>
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_> {
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> {
(**self).as_executor()
}
}
Expand All @@ -89,6 +62,9 @@ impl<E> Queries<E> {
pub fn new(db: E) -> Self {
Self { db }
}
pub fn into_inner(self) -> E {
self.db
}
}
impl<E: AsExecutor> Queries<E> {
pub async fn get_event(&mut self, id: i64) -> Result<GetEventRow, sqlx::Error> {
Expand Down
48 changes: 12 additions & 36 deletions examples/basic/src/queries.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Code generated by sqlc-gen-sqlx v0.1.0. DO NOT EDIT.
// Code generated by sqlc-gen-sqlx v0.1.1. DO NOT EDIT.
// sqlc version: v1.30.0

#![allow(
Expand Down Expand Up @@ -36,62 +36,35 @@ pub struct CreateAuthorRow {
const DELETE_AUTHOR: &str = "DELETE FROM authors WHERE id = $1";
const DELETE_AUTHOR_ROWS: &str = "DELETE FROM authors WHERE id = $1";
pub trait AsExecutor {
type Exec<'c>: sqlx::Executor<'c, Database = sqlx::Postgres>
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_>;
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres>;
}
impl AsExecutor for sqlx::PgPool {
type Exec<'c>
= &'c sqlx::PgPool
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_> {
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> {
&*self
}
}
impl AsExecutor for &sqlx::PgPool {
type Exec<'c>
= &'c sqlx::PgPool
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_> {
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> {
*self
}
}
impl AsExecutor for sqlx::PgConnection {
type Exec<'c>
= &'c mut sqlx::PgConnection
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_> {
self
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> {
&mut *self
}
}
impl AsExecutor for sqlx::Transaction<'_, sqlx::Postgres> {
type Exec<'c>
= &'c mut sqlx::PgConnection
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_> {
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> {
&mut **self
}
}
impl AsExecutor for sqlx::pool::PoolConnection<sqlx::Postgres> {
type Exec<'c>
= &'c mut sqlx::PgConnection
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_> {
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> {
&mut **self
}
}
impl<T: AsExecutor + ?Sized> AsExecutor for &mut T {
type Exec<'c>
= T::Exec<'c>
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_> {
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> {
(**self).as_executor()
}
}
Expand All @@ -102,6 +75,9 @@ impl<E> Queries<E> {
pub fn new(db: E) -> Self {
Self { db }
}
pub fn into_inner(self) -> E {
self.db
}
}
impl<E: AsExecutor> Queries<E> {
pub async fn get_author(&mut self, id: i64) -> Result<GetAuthorRow, sqlx::Error> {
Expand Down
48 changes: 12 additions & 36 deletions examples/batch/src/queries.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Code generated by sqlc-gen-sqlx v0.1.0. DO NOT EDIT.
// Code generated by sqlc-gen-sqlx v0.1.1. DO NOT EDIT.
// sqlc version: v1.30.0

#![allow(
Expand All @@ -15,62 +15,35 @@ pub struct BatchGetAuthorRow {
}
const BATCH_DELETE_AUTHOR: &str = "DELETE FROM authors WHERE id = $1";
pub trait AsExecutor {
type Exec<'c>: sqlx::Executor<'c, Database = sqlx::Postgres>
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_>;
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres>;
}
impl AsExecutor for sqlx::PgPool {
type Exec<'c>
= &'c sqlx::PgPool
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_> {
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> {
&*self
}
}
impl AsExecutor for &sqlx::PgPool {
type Exec<'c>
= &'c sqlx::PgPool
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_> {
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> {
*self
}
}
impl AsExecutor for sqlx::PgConnection {
type Exec<'c>
= &'c mut sqlx::PgConnection
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_> {
self
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> {
&mut *self
}
}
impl AsExecutor for sqlx::Transaction<'_, sqlx::Postgres> {
type Exec<'c>
= &'c mut sqlx::PgConnection
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_> {
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> {
&mut **self
}
}
impl AsExecutor for sqlx::pool::PoolConnection<sqlx::Postgres> {
type Exec<'c>
= &'c mut sqlx::PgConnection
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_> {
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> {
&mut **self
}
}
impl<T: AsExecutor + ?Sized> AsExecutor for &mut T {
type Exec<'c>
= T::Exec<'c>
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_> {
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> {
(**self).as_executor()
}
}
Expand All @@ -81,6 +54,9 @@ impl<E> Queries<E> {
pub fn new(db: E) -> Self {
Self { db }
}
pub fn into_inner(self) -> E {
self.db
}
}
impl<E: AsExecutor> Queries<E> {
pub fn batch_get_author<'a, I>(
Expand Down
48 changes: 12 additions & 36 deletions examples/enums/src/queries.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Code generated by sqlc-gen-sqlx v0.1.0. DO NOT EDIT.
// Code generated by sqlc-gen-sqlx v0.1.1. DO NOT EDIT.
// sqlc version: v1.30.0

#![allow(
Expand Down Expand Up @@ -37,62 +37,35 @@ pub struct CreateUserParams {
}
const CREATE_USER: &str = "INSERT INTO users (name, status) VALUES ($1, $2)";
pub trait AsExecutor {
type Exec<'c>: sqlx::Executor<'c, Database = sqlx::Postgres>
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_>;
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres>;
}
impl AsExecutor for sqlx::PgPool {
type Exec<'c>
= &'c sqlx::PgPool
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_> {
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> {
&*self
}
}
impl AsExecutor for &sqlx::PgPool {
type Exec<'c>
= &'c sqlx::PgPool
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_> {
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> {
*self
}
}
impl AsExecutor for sqlx::PgConnection {
type Exec<'c>
= &'c mut sqlx::PgConnection
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_> {
self
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> {
&mut *self
}
}
impl AsExecutor for sqlx::Transaction<'_, sqlx::Postgres> {
type Exec<'c>
= &'c mut sqlx::PgConnection
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_> {
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> {
&mut **self
}
}
impl AsExecutor for sqlx::pool::PoolConnection<sqlx::Postgres> {
type Exec<'c>
= &'c mut sqlx::PgConnection
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_> {
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> {
&mut **self
}
}
impl<T: AsExecutor + ?Sized> AsExecutor for &mut T {
type Exec<'c>
= T::Exec<'c>
where
Self: 'c;
fn as_executor(&mut self) -> Self::Exec<'_> {
fn as_executor(&mut self) -> impl sqlx::Executor<'_, Database = sqlx::Postgres> {
(**self).as_executor()
}
}
Expand All @@ -103,6 +76,9 @@ impl<E> Queries<E> {
pub fn new(db: E) -> Self {
Self { db }
}
pub fn into_inner(self) -> E {
self.db
}
}
impl<E: AsExecutor> Queries<E> {
pub async fn get_user(&mut self, id: i64) -> Result<GetUserRow, sqlx::Error> {
Expand Down
Loading
Loading