Skip to main content

no_mistakes_postgres_sql/statements/predicates/
projection.rs

1use sqlparser::ast::{Expr, ObjectName, Query, TableFactor};
2
3pub trait Projection {
4    fn table_arm(&self) {}
5
6    #[inline(always)]
7    fn inspect_factor(&self, _: &TableFactor) {}
8
9    #[inline(always)]
10    fn inspect_query(&self, _: &Query) {}
11
12    #[inline(always)]
13    fn relation_name(&self, _: &ObjectName, original: String) -> String {
14        original
15    }
16
17    #[inline(always)]
18    fn qualifier_matches(&self, table: &str, qualifier: &str) -> bool {
19        table.rsplit('.').next() == Some(qualifier)
20    }
21
22    fn map<'a>(
23        &self,
24        predicate: &Expr,
25        other: Option<&Expr>,
26        table: &str,
27        column: String,
28        proven: bool,
29        peers: impl Iterator<Item = &'a str>,
30    ) -> Option<(String, bool)>;
31}
32
33pub(crate) struct Identity;
34
35impl Projection for Identity {
36    #[inline(always)]
37    fn map<'a>(
38        &self,
39        _: &Expr,
40        _: Option<&Expr>,
41        _: &str,
42        column: String,
43        proven: bool,
44        _: impl Iterator<Item = &'a str>,
45    ) -> Option<(String, bool)> {
46        Some((column, proven))
47    }
48}