-
-
Notifications
You must be signed in to change notification settings - Fork 568
SelectThree up to SelectNine #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Use macro to generate each Repeated for up to 9. With #[derive(Clone, Debug)]
pub struct SelectTwo<E, F>
where
E: EntityTrait,
F: EntityTrait,
{
pub(crate) query: SelectStatement,
pub(crate) entity: PhantomData<(E, F)>,
}
impl<E, F> SelectTwo<E, F>
where
E: EntityTrait,
F: EntityTrait,
{
pub(crate) fn new(query: SelectStatement) -> Self {
let myself = Self {
query,
entity: PhantomData,
};
myself.prepare_select()
}
fn prepare_select(mut self) -> Self {
for col in <F::Column as Iterable>::iter() {
let alias = format!("{}{}", SELECT_B, col.to_string().as_str());
self.query.expr(SelectExpr {
expr: col.into_simple_expr(),
alias: Some(SeaRc::new(Alias::new(&alias))),
});
}
self
}
fn apply_alias(mut self, pre: &str) -> Self { ... }
pub fn select_also<G>(mut self, _: G) -> SelectThree<E, F, G>
where
G: EntityTrait,
{
self = self.apply_alias(SELECT_C);
SelectThree::new(self.into_query())
}
}
macro_rules! impl_trait {
( $trait: ident ) => {
impl<E, F> $trait for SelectTwo<E, F>
where
E: EntityTrait,
F: EntityTrait,
{
type QueryStatement = SelectStatement;
fn query(&mut self) -> &mut SelectStatement {
&mut self.query
}
}
};
}
impl_trait!(QuerySelect);
impl_trait!(QueryFilter);
impl_trait!(QueryOrder); |
If we use macro to generate these, will end user be able to infer the type? i.e. will rust-analyser be able to infer & show the |
We probably will delay this feature post |
Ok, not a priority |
Close this for now. Re-open when we are decided to work on this again. |
CI: Clippy, MySQL & Postgres
why did you close this? :( |
there's a newer discussion thread on this. I couldn't find atm. |
Right now we have a tuple based selector for select one and two. Need to think about how to generalise and support up to arity 9 perhaps?
src/query/combine.rs
The text was updated successfully, but these errors were encountered: