use crate::Columns;
#[cfg(feature = "merge-patch")]
use queryweave::FieldValues;
use queryweave::{Conditions, SortKeys};
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum Junction {
And,
Or,
}
#[diagnostic::on_unimplemented(
message = "`{Self}` is not a query `queryweave-sql` can write conditions into",
label = "not a `ConditionsTarget`",
note = "enable the `queryweave-sql` feature of your query builder: `sqlx` (on by default) for sqlx's `QueryBuilder`, `sea-query` for sea-query's (and SeaORM's) statements"
)]
pub trait ConditionsTarget {
fn write_where(&mut self);
fn write_conditions<C: Columns + ?Sized, M>(
&mut self,
conditions: Conditions<M>,
junction: Junction,
);
}
#[diagnostic::on_unimplemented(
message = "`{Self}` is not a query `queryweave-sql` can write an `ORDER BY` into",
label = "not an `OrderByTarget`",
note = "enable the `queryweave-sql` feature of your query builder: `sqlx` (on by default) for sqlx's `QueryBuilder`, `sea-query` for sea-query's (and SeaORM's) statements"
)]
pub trait OrderByTarget {
fn write_order_by<C: Columns + ?Sized, M>(&mut self, sort_keys: SortKeys<M>);
}
#[diagnostic::on_unimplemented(
message = "`{Self}` is not a query `queryweave-sql` can write a page into",
label = "not a `PageTarget`",
note = "enable the `queryweave-sql` feature of your query builder: `sqlx` (on by default) for sqlx's `QueryBuilder`, `sea-query` for sea-query's (and SeaORM's) statements"
)]
pub trait PageTarget {
fn write_page(&mut self, page: Option<u32>, page_size: Option<u32>);
}
#[cfg(feature = "merge-patch")]
#[diagnostic::on_unimplemented(
message = "`{Self}` is not a query `queryweave-sql` can write assignments into",
label = "not an `AssignmentsTarget`",
note = "enable the `queryweave-sql` feature of your query builder: `sqlx` (on by default) for sqlx's `QueryBuilder`, `sea-query` for sea-query's (and SeaORM's) statements"
)]
pub trait AssignmentsTarget {
type Assignments<'target>
where
Self: 'target;
fn write_assignments<C: Columns + ?Sized, M>(
&mut self,
assignments: FieldValues<M>,
) -> Self::Assignments<'_>;
}