1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
use generators::{DatabaseGenerator, TableGenerator};
#[derive(Clone, PartialEq, Eq)]
pub struct Table<T: DatabaseGenerator + TableGenerator + Default>(T, String, Vec<String>);
impl<T: DatabaseGenerator + TableGenerator + Default> Table<T> {
pub fn new(name: &str) -> Self {
return Table(Default::default(), String::from(name), Vec::new());
}
pub fn get_name(&self) -> &String {
return &self.1;
}
pub fn exec(&self) -> String {
let l = self.2.len();
if l == 1 {
return self.2[0].clone();
}
let mut cmd = String::from("(");
let mut ctr = 0;
for item in &self.2 {
cmd.push_str(item);
ctr += 1;
if ctr < l {
cmd.push_str(", ");
}
}
cmd.push(')');
return cmd;
}
pub fn drop_column(&mut self, _: &str) {
unimplemented!();
}
pub fn rename_column(&mut self, _: &str, _: &str) {
unimplemented!();
}
pub fn increments(&mut self) {
self.2.push(T::increments());
}
pub fn integer(&mut self, name: &str) {
self.2.push(T::integer(name));
}
pub fn text(&mut self, name: &str) {
self.2.push(T::text(name));
}
pub fn string(&mut self, name: &str) {
self.2.push(T::string(name));
}
pub fn timestamp(&mut self, name: &str) {
self.2.push(T::timestamp(name));
}
}