odatav4_parser/renderers/
mod.rs

1use crate::ast::QueryOptions;
2
3pub mod mssql;
4pub mod postgresql;
5pub mod sqlite;
6pub mod surrealql;
7pub mod snowflake;
8pub mod filter;
9
10use std::collections::HashMap;
11
12/// Result of rendering a query, containing the SQL string and collected parameters
13#[derive(Debug, Clone, PartialEq)]
14pub struct RenderedQuery {
15    pub sql: String,
16    pub params: HashMap<String, String>,
17}
18
19impl RenderedQuery {
20    pub fn new(sql: String, params: HashMap<String, String>) -> Self {
21        Self { sql, params }
22    }
23}
24
25impl std::fmt::Display for RenderedQuery {
26    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
27        write!(f, "{}", self.sql)
28    }
29}
30
31/// Trait for rendering OData query options to SQL
32pub trait SqlRenderer {
33    /// Render the query options to SQL for a given table
34    fn render(&mut self, table_name: &str, options: &QueryOptions) -> RenderedQuery;
35}