rbatis_codegen/codegen/syntax_tree_pysql/
set_node.rs1use crate::codegen::syntax_tree_pysql::{Name, NodeType, ToHtml};
2
3#[derive(Clone, Debug, Eq, PartialEq)]
20pub struct SetNode {
21 pub childs: Vec<NodeType>,
22 pub collection: String,
23 pub skips: String,
24 pub skip_null: bool,
25}
26
27impl Name for SetNode {
28 fn name() -> &'static str {
29 "set"
30 }
31}
32
33
34impl ToHtml for SetNode {
35 fn as_html(&self) -> String {
36 let mut childs_html = String::new();
37 for x in &self.childs {
38 childs_html.push_str(&x.as_html());
39 }
40
41 let mut attrs_string = String::new();
42 if !self.collection.is_empty() {
43 attrs_string.push_str(&format!(" collection=\"{}\"", self.collection));
44 }
45 if !self.skips.is_empty() {
46 attrs_string.push_str(&format!(" skips=\"{}\"", self.skips));
47 }
48 if self.skip_null {
49 attrs_string.push_str(" skip_null=\"true\"");
50 }
51
52 format!("<set{}>{}</set>", attrs_string, childs_html)
53 }
54}