Fix follow IDs (#455)

* Generate valid IDs for Follow

Fixes #449

* Use the new post-insert hook for all the models

* Fix plume-cli build
This commit is contained in:
Baptiste Gelez
2019-03-04 21:35:03 +01:00
committed by GitHub
parent 9b48b8a846
commit 2a188abfa1
12 changed files with 162 additions and 181 deletions
+7 -1
View File
@@ -235,13 +235,19 @@ macro_rules! get {
/// ```
macro_rules! insert {
($table:ident, $from:ident) => {
insert!($table, $from, |x, _conn| { Ok(x) });
};
($table:ident, $from:ident, |$val:ident, $conn:ident | $after:block) => {
last!($table);
pub fn insert(conn: &crate::Connection, new: $from) -> Result<Self> {
diesel::insert_into($table::table)
.values(new)
.execute(conn)?;
Self::last(conn)
#[allow(unused_mut)]
let mut $val = Self::last(conn)?;
let $conn = conn;
$after
}
};
}