arysn 0.5.3

ORM code generator
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#[derive(Clone, Debug)]
pub struct OrderItem {
    pub table: String,
    pub field: &'static str,
    pub asc_or_desc: &'static str,
}

impl OrderItem {
    pub fn to_sql(&self) -> String {
        if self.table.is_empty() {
            // order().by_string_literal_asc/desc("...")
            format!("{} {}", self.field, self.asc_or_desc)
        } else {
            format!("{}.{} {}", &self.table, self.field, self.asc_or_desc)
        }
    }
}