use super::{IndexHint, IndexHintScope, IndexHintType};
use crate::{IntoIden, SelectStatement};
pub trait MySqlSelectStatementExt {
fn use_index<I>(&mut self, index: I, scope: IndexHintScope) -> &mut Self
where
I: IntoIden;
fn force_index<I>(&mut self, index: I, scope: IndexHintScope) -> &mut Self
where
I: IntoIden;
fn ignore_index<I>(&mut self, index: I, scope: IndexHintScope) -> &mut Self
where
I: IntoIden;
}
impl MySqlSelectStatementExt for SelectStatement {
fn use_index<I>(&mut self, index: I, scope: IndexHintScope) -> &mut Self
where
I: IntoIden,
{
self.index_hints.push(IndexHint {
index: index.into_iden(),
r#type: IndexHintType::Use,
scope,
});
self
}
fn force_index<I>(&mut self, index: I, scope: IndexHintScope) -> &mut Self
where
I: IntoIden,
{
self.index_hints.push(IndexHint {
index: index.into_iden(),
r#type: IndexHintType::Force,
scope,
});
self
}
fn ignore_index<I>(&mut self, index: I, scope: IndexHintScope) -> &mut Self
where
I: IntoIden,
{
self.index_hints.push(IndexHint {
index: index.into_iden(),
r#type: IndexHintType::Ignore,
scope,
});
self
}
}