rbatis_codegen/codegen/syntax_tree_pysql/
bind_node.rs

1use crate::codegen::syntax_tree_pysql::{DefaultName, Name, ToHtml};
2
3/// Represents a `bind` or `let` node in py_sql.
4/// It's used to assign a value to a variable within the SQL query.
5/// 
6/// # Examples
7/// 
8/// PySQL syntax:
9/// ```py
10/// let name = 'value'
11/// bind name = 'value'
12/// ```
13#[derive(Clone, Debug, Eq, PartialEq)]
14pub struct BindNode {
15    pub name: String,
16    pub value: String,
17}
18
19impl DefaultName for BindNode {
20    fn default_name() -> &'static str {
21        "let"
22    }
23}
24
25impl Name for BindNode {
26    fn name() -> &'static str {
27        "bind"
28    }
29}
30
31
32impl ToHtml for BindNode {
33    fn as_html(&self) -> String {
34        format!("<bind name=\"{}\" value=\"{}\"/>", self.name, self.value)
35    }
36}