arysn/order_item.rs
1#[derive(Clone, Debug)]
2pub struct OrderItem {
3 pub table: String,
4 pub field: &'static str,
5 pub asc_or_desc: &'static str,
6}
7
8impl OrderItem {
9 pub fn to_sql(&self) -> String {
10 if self.table.is_empty() {
11 // order().by_string_literal_asc/desc("...")
12 format!("{} {}", self.field, self.asc_or_desc)
13 } else {
14 format!("{}.{} {}", &self.table, self.field, self.asc_or_desc)
15 }
16 }
17}