besu_postgres/
dialect.rs

1use std::borrow::Cow;
2
3use besu::{DeleteOperation, Dialect, InsertOperation, SelectOperation, UpdateOperation};
4
5/// Postgres dialect implementation.
6#[derive(Debug)]
7pub struct Postgres;
8
9impl Dialect for Postgres {
10    fn positional_param(idx: usize) -> Cow<'static, str> {
11        format!("${}", idx + 1).into()
12    }
13
14    fn select<V: Default>(op: &SelectOperation) -> (String, V) {
15        // TODO: Don't use `*`, list all columns!
16        let q = format!(r#"SELECT * FROM "{}""#, op.table);
17
18        // for (i, (col, val)) in op.where_equals.iter().enumerate() {
19        //     if i == 0 {
20        //         q.push_str(" WHERE ");
21        //     } else {
22        //         q.push_str(" AND ");
23        //     }
24        //     q.push_str(col);
25        //     q.push_str(" = ");
26        //     q.push_str(Self::positional_param(i).as_ref());
27        // }
28
29        (q, Default::default())
30    }
31
32    #[allow(clippy::todo)]
33    fn insert<V>(_op: &InsertOperation) -> (String, V) {
34        todo!()
35    }
36
37    #[allow(clippy::todo)]
38    fn update<V>(_op: &UpdateOperation) -> (String, V) {
39        todo!()
40    }
41
42    #[allow(clippy::todo)]
43    fn delete<V>(_op: &DeleteOperation) -> (String, V) {
44        todo!()
45    }
46}