about summary refs log tree commit diff
path: root/finito-postgres/src/lib.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2018-09-26T16·43+0200
committerVincent Ambo <mail@tazj.in>2018-09-26T16·43+0200
commit7e5592f0d186dde6e3e10be51efce2bdfc7483d0 (patch)
tree33e744f6556cd350fbbd699bfec2fa22f8597d96 /finito-postgres/src/lib.rs
parent6254d056204b41b346367f9f03a4407b6c2a1a1a (diff)
fix(postgres): Minor fixes in Postgres queries and handling
Diffstat (limited to 'finito-postgres/src/lib.rs')
-rw-r--r--finito-postgres/src/lib.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/finito-postgres/src/lib.rs b/finito-postgres/src/lib.rs
index 6e1815a69fa1..80200f8a43cd 100644
--- a/finito-postgres/src/lib.rs
+++ b/finito-postgres/src/lib.rs
@@ -67,6 +67,7 @@ struct EventT {
 
 /// This enum represents the possible statuses an action can be in.
 #[derive(Debug, ToSql, FromSql)]
+#[postgres(name = "actionstatus")]
 enum ActionStatus {
     /// The action was requested but has not run yet.
     Pending,
@@ -195,7 +196,7 @@ fn insert_action<C, S>(conn: &C,
     S: FSM,
     S::Action: Serialize {
     let query = r#"
-      INSERT INTO actions (id, fsm, fsm_id, event_id, action, status)
+      INSERT INTO actions (id, fsm, fsm_id, event_id, content, status)
       VALUES ($1, $2, $3, $4, $5, $6)
     "#;
 
@@ -239,7 +240,7 @@ pub fn get_machine<C, S>(conn: &C,
     C: GenericConnection,
     S: FSM + DeserializeOwned {
     let query = r#"
-      SELECT (id, created, fsm, state) FROM machines WHERE id = $1
+      SELECT id, created, fsm, state FROM machines WHERE id = $1
     "#;
 
     // If the machine is being fetched in the context of a
@@ -252,7 +253,7 @@ pub fn get_machine<C, S>(conn: &C,
 
     let rows = conn.query(&query, &[&id.to_uuid()]).expect("TODO");
     let mut machines = rows.into_iter().map(|row| MachineT {
-        id: row.get(0),
+        id: id.to_uuid(),
         created: row.get(1),
         fsm: row.get(2),
         state: row.get(3),
@@ -300,5 +301,7 @@ pub fn advance<C, S>(conn: &C,
 
     // And finally the state is updated:
     update_state(&tx, id, &new_state).expect("TODO");
+    tx.commit().expect("TODO");
+
     Ok(new_state)
 }