diff --git a/Cargo.toml b/Cargo.toml index eb59fdb..978e554 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ atmosphere-core = { version = "=0.3.0", path = "atmosphere-core" } atmosphere-macros = { version = "=0.3.0", path = "atmosphere-macros" } async-trait = "0.1" lazy_static = "1" -sqlx = { version = "0.7", features = ["chrono"] } +sqlx = { version = "0.8", features = ["chrono"] } thiserror = "1" [package] @@ -47,7 +47,7 @@ postgres = ["atmosphere-core/postgres", "atmosphere-macros/postgres"] sqlite = ["atmosphere-core/sqlite", "atmosphere-macros/sqlite"] [dev-dependencies] -sqlx = { version = "0.7", features = [ +sqlx = { version = "0.8", features = [ "runtime-tokio-rustls", "any", "sqlite", diff --git a/atmosphere-core/src/bind.rs b/atmosphere-core/src/bind.rs index 8321c63..44ea2ce 100644 --- a/atmosphere-core/src/bind.rs +++ b/atmosphere-core/src/bind.rs @@ -22,7 +22,7 @@ use crate::{Column, Result, Table}; use miette::Diagnostic; -use sqlx::database::HasArguments; +use sqlx::database::Database; use sqlx::query::QueryAs; use sqlx::{Encode, QueryBuilder, Type}; use thiserror::Error; @@ -40,7 +40,7 @@ pub enum BindError { Unknown(&'static str), } -type Query<'q, DB> = sqlx::query::Query<'q, DB, >::Arguments>; +type Query<'q, DB> = sqlx::query::Query<'q, DB, ::Arguments<'q>>; /// Trait for dynamic binding of values. /// @@ -66,7 +66,7 @@ impl<'q> Bindable<'q> for Query<'q, crate::Driver> { } impl<'q, E> Bindable<'q> - for QueryAs<'q, crate::Driver, E, >::Arguments> + for QueryAs<'q, crate::Driver, E, ::Arguments<'q>> { fn dyn_bind + Type>( self, diff --git a/atmosphere-core/src/rel.rs b/atmosphere-core/src/rel.rs index 4ab52d9..08db020 100644 --- a/atmosphere-core/src/rel.rs +++ b/atmosphere-core/src/rel.rs @@ -5,7 +5,7 @@ //! relationships in a database using SQLx. use async_trait::async_trait; -use sqlx::database::HasArguments; +use sqlx::database::Database; use sqlx::{Executor, IntoArguments}; use crate::bind::Bind; @@ -31,8 +31,7 @@ where async fn resolve<'e, E>(&self, executor: E) -> Result where E: Executor<'e, Database = crate::Driver>, - for<'q> >::Arguments: - IntoArguments<'q, crate::Driver> + Send, + for<'q> ::Arguments<'q>: IntoArguments<'q, crate::Driver> + Send, { let Query { builder, .. } = sql::select::(); @@ -65,8 +64,7 @@ where async fn resolve<'e, E>(&self, executor: E) -> Result> where E: Executor<'e, Database = crate::Driver>, - for<'q> >::Arguments: - IntoArguments<'q, crate::Driver> + Send, + for<'q> ::Arguments<'q>: IntoArguments<'q, crate::Driver> + Send, { let Query { builder, .. } = sql::select_by::(Other::FOREIGN_KEY.as_col()); @@ -87,8 +85,7 @@ where async fn resolve_by<'e, E>(executor: E, pk: &Self::PrimaryKey) -> Result> where E: Executor<'e, Database = crate::Driver>, - for<'q> >::Arguments: - IntoArguments<'q, crate::Driver> + Send, + for<'q> ::Arguments<'q>: IntoArguments<'q, crate::Driver> + Send, { let Query { builder, .. } = sql::select_by::(Other::FOREIGN_KEY.as_col()); @@ -108,8 +105,7 @@ where ) -> Result<::QueryResult> where E: Executor<'e, Database = crate::Driver>, - for<'q> >::Arguments: - IntoArguments<'q, crate::Driver> + Send, + for<'q> ::Arguments<'q>: IntoArguments<'q, crate::Driver> + Send, { let Query { builder, .. } = sql::delete_by::(Other::FOREIGN_KEY.as_col()); diff --git a/atmosphere-core/src/schema/create.rs b/atmosphere-core/src/schema/create.rs index 56311dc..d08a4c2 100644 --- a/atmosphere-core/src/schema/create.rs +++ b/atmosphere-core/src/schema/create.rs @@ -6,7 +6,7 @@ use crate::{ }; use async_trait::async_trait; -use sqlx::{database::HasArguments, Executor, IntoArguments}; +use sqlx::{database::Database, Executor, IntoArguments}; /// Trait for creating rows in a database. /// @@ -25,8 +25,7 @@ pub trait Create: Table + Bind + Hooks + Sync + 'static { ) -> Result<::QueryResult> where E: Executor<'e, Database = crate::Driver>, - for<'q> >::Arguments: - IntoArguments<'q, crate::Driver> + Send; + for<'q> ::Arguments<'q>: IntoArguments<'q, crate::Driver> + Send; } #[async_trait] @@ -40,8 +39,7 @@ where ) -> Result<::QueryResult> where E: Executor<'e, Database = crate::Driver>, - for<'q> >::Arguments: - IntoArguments<'q, crate::Driver> + Send, + for<'q> ::Arguments<'q>: IntoArguments<'q, crate::Driver> + Send, { let query = crate::runtime::sql::insert::(); diff --git a/atmosphere-core/src/schema/delete.rs b/atmosphere-core/src/schema/delete.rs index 543ec58..f9c99f6 100644 --- a/atmosphere-core/src/schema/delete.rs +++ b/atmosphere-core/src/schema/delete.rs @@ -6,7 +6,7 @@ use crate::{ }; use async_trait::async_trait; -use sqlx::{database::HasArguments, Database, Executor, IntoArguments}; +use sqlx::{Database, Executor, IntoArguments}; /// Trait for deleting rows from a database. /// @@ -25,8 +25,7 @@ pub trait Delete: Table + Bind + Hooks + Send + Sync + Unpin + 'static { ) -> Result<::QueryResult> where E: Executor<'e, Database = crate::Driver>, - for<'q> >::Arguments: - IntoArguments<'q, crate::Driver> + Send; + for<'q> ::Arguments<'q>: IntoArguments<'q, crate::Driver> + Send; /// Deletes a row from the database based on its primary key. This method is particularly /// useful for deleting entities when only the primary key is available. @@ -36,8 +35,7 @@ pub trait Delete: Table + Bind + Hooks + Send + Sync + Unpin + 'static { ) -> Result<::QueryResult> where E: Executor<'e, Database = crate::Driver>, - for<'q> >::Arguments: - IntoArguments<'q, crate::Driver> + Send; + for<'q> ::Arguments<'q>: IntoArguments<'q, crate::Driver> + Send; } #[async_trait] @@ -51,8 +49,7 @@ where ) -> Result<::QueryResult> where E: Executor<'e, Database = crate::Driver>, - for<'q> >::Arguments: - IntoArguments<'q, crate::Driver> + Send, + for<'q> ::Arguments<'q>: IntoArguments<'q, crate::Driver> + Send, { let query = crate::runtime::sql::delete::(); @@ -94,8 +91,7 @@ where ) -> Result<::QueryResult> where E: Executor<'e, Database = crate::Driver>, - for<'q> >::Arguments: - IntoArguments<'q, crate::Driver> + Send, + for<'q> ::Arguments<'q>: IntoArguments<'q, crate::Driver> + Send, { let query = crate::runtime::sql::delete::(); diff --git a/atmosphere-core/src/schema/read.rs b/atmosphere-core/src/schema/read.rs index 92eada3..a763d16 100644 --- a/atmosphere-core/src/schema/read.rs +++ b/atmosphere-core/src/schema/read.rs @@ -6,7 +6,7 @@ use crate::{ }; use async_trait::async_trait; -use sqlx::{database::HasArguments, Executor, IntoArguments}; +use sqlx::{database::Database, Executor, IntoArguments}; /// Trait for reading rows from a database. /// @@ -22,8 +22,7 @@ pub trait Read: Table + Bind + Hooks + Send + Sync + Unpin + 'static { async fn read<'e, E>(executor: E, pk: &Self::PrimaryKey) -> Result where E: Executor<'e, Database = crate::Driver>, - for<'q> >::Arguments: - IntoArguments<'q, crate::Driver> + Send; + for<'q> ::Arguments<'q>: IntoArguments<'q, crate::Driver> + Send; /// Finds and retrieves a row by its primary key. This method constructs a query to fetch /// a single row based on the primary key, executes it, and returns the result, optionally @@ -31,16 +30,14 @@ pub trait Read: Table + Bind + Hooks + Send + Sync + Unpin + 'static { async fn find<'e, E>(executor: E, pk: &Self::PrimaryKey) -> Result> where E: Executor<'e, Database = crate::Driver>, - for<'q> >::Arguments: - IntoArguments<'q, crate::Driver> + Send; + for<'q> ::Arguments<'q>: IntoArguments<'q, crate::Driver> + Send; /// Retrieves all rows from the table. This method is useful for fetching the complete /// dataset of a table, executing a query to return all rows, and applying hooks as needed. async fn read_all<'e, E>(executor: E) -> Result> where E: Executor<'e, Database = crate::Driver>, - for<'q> >::Arguments: - IntoArguments<'q, crate::Driver> + Send; + for<'q> ::Arguments<'q>: IntoArguments<'q, crate::Driver> + Send; /// Reloads the current entity from the database. This method is designed to update the entity /// instance with the latest data from the database, ensuring that it reflects the current @@ -48,8 +45,7 @@ pub trait Read: Table + Bind + Hooks + Send + Sync + Unpin + 'static { async fn reload<'e, E>(&mut self, executor: E) -> Result<()> where E: Executor<'e, Database = crate::Driver>, - for<'q> >::Arguments: - IntoArguments<'q, crate::Driver> + Send; + for<'q> ::Arguments<'q>: IntoArguments<'q, crate::Driver> + Send; } #[async_trait] @@ -60,8 +56,7 @@ where async fn read<'e, E>(executor: E, pk: &Self::PrimaryKey) -> Result where E: Executor<'e, Database = crate::Driver>, - for<'q> >::Arguments: - IntoArguments<'q, crate::Driver> + Send, + for<'q> ::Arguments<'q>: IntoArguments<'q, crate::Driver> + Send, { let query = crate::runtime::sql::select::(); @@ -94,8 +89,7 @@ where async fn find<'e, E>(executor: E, pk: &Self::PrimaryKey) -> Result> where E: Executor<'e, Database = crate::Driver>, - for<'q> >::Arguments: - IntoArguments<'q, crate::Driver> + Send, + for<'q> ::Arguments<'q>: IntoArguments<'q, crate::Driver> + Send, { let query = crate::runtime::sql::select::(); @@ -128,8 +122,7 @@ where async fn read_all<'e, E>(executor: E) -> Result> where E: Executor<'e, Database = crate::Driver>, - for<'q> >::Arguments: - IntoArguments<'q, crate::Driver> + Send, + for<'q> ::Arguments<'q>: IntoArguments<'q, crate::Driver> + Send, { let query = crate::runtime::sql::select_all::(); @@ -156,8 +149,7 @@ where async fn reload<'e, E>(&mut self, executor: E) -> Result<()> where E: Executor<'e, Database = crate::Driver>, - for<'q> >::Arguments: - IntoArguments<'q, crate::Driver> + Send, + for<'q> ::Arguments<'q>: IntoArguments<'q, crate::Driver> + Send, { let query = crate::runtime::sql::select_by::(T::PRIMARY_KEY.as_col()); diff --git a/atmosphere-core/src/schema/update.rs b/atmosphere-core/src/schema/update.rs index 4bc6caf..d0a08c3 100644 --- a/atmosphere-core/src/schema/update.rs +++ b/atmosphere-core/src/schema/update.rs @@ -6,7 +6,7 @@ use crate::{ }; use async_trait::async_trait; -use sqlx::{database::HasArguments, Database, Executor, IntoArguments}; +use sqlx::{Database, Executor, IntoArguments}; /// Update rows in a database. /// @@ -25,8 +25,7 @@ pub trait Update: Table + Bind + Hooks + Send + Sync + Unpin + 'static { ) -> Result<::QueryResult> where E: Executor<'e, Database = crate::Driver>, - for<'q> >::Arguments: - IntoArguments<'q, crate::Driver> + Send; + for<'q> ::Arguments<'q>: IntoArguments<'q, crate::Driver> + Send; /// Similar to `update`, but either updates an existing row or inserts a new one if it does not /// exist, depending on the primary key's presence and uniqueness. @@ -36,8 +35,7 @@ pub trait Update: Table + Bind + Hooks + Send + Sync + Unpin + 'static { ) -> Result<::QueryResult> where E: Executor<'e, Database = crate::Driver>, - for<'q> >::Arguments: - IntoArguments<'q, crate::Driver> + Send; + for<'q> ::Arguments<'q>: IntoArguments<'q, crate::Driver> + Send; } #[async_trait] @@ -51,8 +49,7 @@ where ) -> Result<::QueryResult> where E: Executor<'e, Database = crate::Driver>, - for<'q> >::Arguments: - IntoArguments<'q, crate::Driver> + Send, + for<'q> ::Arguments<'q>: IntoArguments<'q, crate::Driver> + Send, { let query = crate::runtime::sql::update::(); @@ -89,8 +86,7 @@ where ) -> Result<::QueryResult> where E: Executor<'e, Database = crate::Driver>, - for<'q> >::Arguments: - IntoArguments<'q, crate::Driver> + Send, + for<'q> ::Arguments<'q>: IntoArguments<'q, crate::Driver> + Send, { let query = crate::runtime::sql::upsert::(); diff --git a/atmosphere-macros/src/derive/queries/unique.rs b/atmosphere-macros/src/derive/queries/unique.rs index 3d327f6..8fd8ccf 100644 --- a/atmosphere-macros/src/derive/queries/unique.rs +++ b/atmosphere-macros/src/derive/queries/unique.rs @@ -42,7 +42,7 @@ pub fn queries(table: &Table) -> TokenStream { ) -> ::atmosphere::Result> where E: ::atmosphere::sqlx::Executor<'e, Database = ::atmosphere::Driver>, - for<'q> <::atmosphere::Driver as ::atmosphere::sqlx::database::HasArguments<'q>>::Arguments: + for<'q> <::atmosphere::Driver as ::atmosphere::sqlx::database::Database>::Arguments<'q>: ::atmosphere::sqlx::IntoArguments<'q, ::atmosphere::Driver> + Send { use ::atmosphere::{ @@ -70,7 +70,7 @@ pub fn queries(table: &Table) -> TokenStream { ) -> ::atmosphere::Result<<::atmosphere::Driver as ::atmosphere::sqlx::Database>::QueryResult> where E: ::atmosphere::sqlx::Executor<'e, Database = ::atmosphere::Driver>, - for<'q> <::atmosphere::Driver as ::atmosphere::sqlx::database::HasArguments<'q>>::Arguments: + for<'q> <::atmosphere::Driver as ::atmosphere::sqlx::database::Database>::Arguments<'q>: ::atmosphere::sqlx::IntoArguments<'q, ::atmosphere::Driver> + Send { use ::atmosphere::{ diff --git a/atmosphere-macros/src/derive/relationships.rs b/atmosphere-macros/src/derive/relationships.rs index fe92ae4..a8b7d13 100644 --- a/atmosphere-macros/src/derive/relationships.rs +++ b/atmosphere-macros/src/derive/relationships.rs @@ -43,7 +43,7 @@ pub fn relationships(table: &Table) -> TokenStream { ) -> ::atmosphere::Result<#other> where E: ::atmosphere::sqlx::Executor<'e, Database = ::atmosphere::Driver>, - for<'q> <::atmosphere::Driver as ::atmosphere::sqlx::database::HasArguments<'q>>::Arguments: + for<'q> <::atmosphere::Driver as ::atmosphere::sqlx::database::Database>::Arguments<'q>: ::atmosphere::sqlx::IntoArguments<'q, ::atmosphere::Driver> + Send { <#ident as ::atmosphere::rel::RefersTo<#other>>::resolve(&self, executor).await } @@ -55,7 +55,7 @@ pub fn relationships(table: &Table) -> TokenStream { ) -> ::atmosphere::Result> where E: ::atmosphere::sqlx::Executor<'e, Database = ::atmosphere::Driver>, - for<'q> <::atmosphere::Driver as ::atmosphere::sqlx::database::HasArguments<'q>>::Arguments: + for<'q> <::atmosphere::Driver as ::atmosphere::sqlx::database::Database>::Arguments<'q>: ::atmosphere::sqlx::IntoArguments<'q, ::atmosphere::Driver> + Send { <#other as ::atmosphere::rel::ReferredBy<#ident>>::resolve_by(executor, pk).await } @@ -69,7 +69,7 @@ pub fn relationships(table: &Table) -> TokenStream { ) -> ::atmosphere::Result> where E: ::atmosphere::sqlx::Executor<'e, Database = ::atmosphere::Driver>, - for<'q> <::atmosphere::Driver as ::atmosphere::sqlx::database::HasArguments<'q>>::Arguments: + for<'q> <::atmosphere::Driver as ::atmosphere::sqlx::database::Database>::Arguments<'q>: ::atmosphere::sqlx::IntoArguments<'q, ::atmosphere::Driver> + Send { <#other as ::atmosphere::rel::ReferredBy<#ident>>::resolve(&self, executor).await } @@ -80,7 +80,7 @@ pub fn relationships(table: &Table) -> TokenStream { ) -> ::atmosphere::Result<<::atmosphere::Driver as ::atmosphere::sqlx::Database>::QueryResult> where E: ::atmosphere::sqlx::Executor<'e, Database = ::atmosphere::Driver>, - for<'q> <::atmosphere::Driver as ::atmosphere::sqlx::database::HasArguments<'q>>::Arguments: + for<'q> <::atmosphere::Driver as ::atmosphere::sqlx::database::Database>::Arguments<'q>: ::atmosphere::sqlx::IntoArguments<'q, ::atmosphere::Driver> + Send { <#other as ::atmosphere::rel::ReferredBy<#ident>>::delete_all(&self, executor).await }