easy_sql/markers/
query.rs1use easy_macros::always_context;
2
3use crate::{Driver, traits::ToConvert};
4
5#[always_context]
6#[diagnostic::on_unimplemented(
10 message = "Type `{T}` is not a part of requested tables clause in this query, nor it is not an Output type (or using columns from Output type might not be supported in this position)"
11)]
12pub trait HasTable<T> {}
13
14#[always_context]
15pub trait HasTableJoined<T> {
19 type MaybeOption<Y>;
20
21 fn into_maybe_option<Y>(t: Y) -> Self::MaybeOption<Y>;
22}
23
24#[always_context]
25#[diagnostic::on_unimplemented(
29 message = "Only types representing single row are allowed as output in query_lazy! calls."
30)]
31pub trait ToConvertSingle<D: Driver>: ToConvert<D> + sqlx::Row {}
32
33#[diagnostic::on_unimplemented(
34 message = "Providing arguments for the selected output type is required. Tip: add parentheses with the inputs, after the selected output type, Example: {Self}(\"Example joined string start: \" || joined_column, 26)"
35)]
36pub trait NormalSelect {}
40
41#[diagnostic::on_unimplemented(
42 message = "Selected output type is not requesting any input arguments. Tip: remove parentheses with the inputs, after the selected output type"
43)]
44pub trait WithArgsSelect {}
48
49#[diagnostic::on_unimplemented(message = "UPDATE and DELETE queries do not support joined tables.")]
53pub trait NotJoinedTable {}
54
55pub trait OutputData<Table> {
60 type SelectProvider;
61}
62
63impl<T: OutputData<Table>, Table> OutputData<Table> for Vec<T> {
64 type SelectProvider = T::SelectProvider;
65}
66
67impl<T: OutputData<Table>, Table> OutputData<Table> for Option<T> {
68 type SelectProvider = T::SelectProvider;
69}
70impl<Table> OutputData<Table> for () {
71 type SelectProvider = ();
72}