good_ormning/sqlite/query/
select.rs

1use {
2    super::{
3        expr::{
4            ExprType,
5        },
6        select_body::{
7            build_select_junction,
8            SelectBody,
9            SelectJunction,
10        },
11        utils::{
12            build_with,
13            QueryBody,
14            With,
15        },
16    },
17    crate::{
18        sqlite::{
19            QueryResCount,
20        },
21        utils::Tokens,
22    },
23    std::collections::HashMap,
24};
25
26#[derive(Clone, Debug)]
27pub struct Select {
28    pub with: Option<With>,
29    pub body: SelectBody,
30    pub body_junctions: Vec<SelectJunction>,
31}
32
33impl QueryBody for Select {
34    fn build(
35        &self,
36        ctx: &mut super::utils::SqliteQueryCtx,
37        path: &rpds::Vector<String>,
38        res_count: QueryResCount,
39    ) -> (ExprType, Tokens) {
40        let mut out = Tokens::new();
41        if let Some(w) = &self.with {
42            out.s(&build_with(ctx, path, w).to_string());
43        }
44        let body: (ExprType, Tokens) = self.body.build(ctx, &HashMap::new(), path, res_count);
45        out.s(&body.1.to_string());
46        out.s(&build_select_junction(ctx, path, &body.0, &self.body_junctions).to_string());
47        return (body.0, out);
48    }
49}