fixes some misbehaviour
This commit is contained in:
@@ -3,7 +3,7 @@ use diesel::expression::exists::Exists;
|
||||
use diesel::prelude::*;
|
||||
|
||||
use crate::schema::{items, looted};
|
||||
use crate::{DbConnection, QueryResult, Update, UpdateResult };
|
||||
use crate::{DbConnection, QueryResult, Update, UpdateResult, Claims };
|
||||
type ItemColumns = (looted::id, looted::name, looted::base_price);
|
||||
const ITEM_COLUMNS: ItemColumns = (looted::id, looted::name, looted::base_price);
|
||||
type OwnedBy = Select<OwnedLoot, ItemColumns>;
|
||||
@@ -28,8 +28,15 @@ impl Item {
|
||||
}
|
||||
|
||||
pub fn remove(self, conn: &DbConnection) -> UpdateResult {
|
||||
diesel::delete(looted::table.find(self.id)).execute(conn)?;
|
||||
Ok(Update::ItemRemoved(self))
|
||||
conn.transaction(
|
||||
|| -> UpdateResult
|
||||
{
|
||||
Claims(conn).delete_for_loot(self.id)?;
|
||||
diesel::delete(looted::table.find(self.id)).execute(conn)?;
|
||||
|
||||
Ok(Update::ItemRemoved(self))
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fn owned_by(player: i32) -> OwnedBy {
|
||||
|
||||
Reference in New Issue
Block a user