drizzle_core/expr/
subquery.rs1use crate::traits::SQLParam;
7use crate::types::DataType;
8
9use super::Expr;
10
11pub trait SubqueryType<'a, V: SQLParam> {
14 type SQLType: DataType;
16}
17
18impl<'a, V, E> SubqueryType<'a, V> for crate::row::SelectCols<(E,)>
19where
20 V: SQLParam + 'a,
21 E: Expr<'a, V>,
22{
23 type SQLType = E::SQLType;
24}
25
26macro_rules! impl_subquery_type_tuple {
27 ($($E:ident),+; $($idx:tt),+) => {
28 impl<'a, V, $($E),+> SubqueryType<'a, V> for crate::row::SelectCols<($($E,)+)>
29 where
30 V: SQLParam + 'a,
31 $($E: Expr<'a, V>,)+
32 {
33 type SQLType = ($($E::SQLType,)+);
34 }
35 };
36}
37
38macro_rules! with_col_sizes_2_to_8 {
39 ($callback:ident) => {
40 seq_tuples!(@from $callback
41 [E0]
42 [0];
43 (E1,1) (E2,2) (E3,3)
44 (E4,4) (E5,5) (E6,6) (E7,7)
45 );
46 };
47}
48
49with_col_sizes_2_to_8!(impl_subquery_type_tuple);
50
51#[cfg(any(
52 feature = "col16",
53 feature = "col32",
54 feature = "col64",
55 feature = "col128",
56 feature = "col200"
57))]
58with_col_sizes_16!(impl_subquery_type_tuple);
59
60#[cfg(any(
61 feature = "col32",
62 feature = "col64",
63 feature = "col128",
64 feature = "col200"
65))]
66with_col_sizes_32!(impl_subquery_type_tuple);
67
68#[cfg(any(feature = "col64", feature = "col128", feature = "col200"))]
69with_col_sizes_64!(impl_subquery_type_tuple);
70
71#[cfg(any(feature = "col128", feature = "col200"))]
72with_col_sizes_128!(impl_subquery_type_tuple);
73
74#[cfg(feature = "col200")]
75with_col_sizes_200!(impl_subquery_type_tuple);
76
77impl<'a, V, M, Scope, Used> SubqueryType<'a, V> for crate::row::Scoped<M, Scope, Used>
78where
79 V: SQLParam + 'a,
80 M: SubqueryType<'a, V>,
81{
82 type SQLType = M::SQLType;
83}