FIX: changed variable naming and added needed import
This commit is contained in:
parent
0250047f57
commit
d1b157de7e
|
@ -5,9 +5,7 @@ use crate::database::controller::connector::establish_connection;
|
|||
use diesel::{RunQueryDsl, ExpressionMethods};
|
||||
use diesel::query_dsl::methods::{OrderDsl,OffsetDsl};
|
||||
use diesel::query_dsl::limit_dsl::LimitDsl;
|
||||
|
||||
|
||||
|
||||
use crate::schema::groups::dsl::entity_id;
|
||||
|
||||
|
||||
pub fn get_vehicle_categories(settings: &State<Settings>) -> Result<Vec<VehicleCategory>, diesel::result::Error> {
|
||||
|
@ -70,13 +68,19 @@ pub fn add_vehicle(settings: &State<Settings>, vehicle: Vehicle) -> Result<Vehic
|
|||
}
|
||||
|
||||
/// Removes vehicle with given id from database
|
||||
pub fn remove_vehicle(settings: &State<Settings>, vehicle_id2: uuid::Uuid) -> Result<(), diesel::result::Error>{
|
||||
pub fn remove_vehicle(settings: &State<Settings>, vehicle_id: uuid::Uuid) -> Result<(), diesel::result::Error>{
|
||||
use crate::schema::vehicles::dsl::*;
|
||||
use crate::diesel::QueryDsl;
|
||||
|
||||
let connection = establish_connection(settings);
|
||||
|
||||
match diesel::delete(vehicles).filter(vehicle_id.eq(vehicle_id2)).execute(&connection){
|
||||
Ok(()) => Ok(()),
|
||||
match diesel::delete(vehicles.filter(entity_id.eq(vehicle_id))).execute(&connection){
|
||||
Ok(count) => {
|
||||
if count != 1{
|
||||
error!("Something went wrong deleting vehicle {}: count was {} instead of 1", vehicle_id, count);
|
||||
}
|
||||
Ok(())
|
||||
},
|
||||
Err(e) => {
|
||||
error!("Couldn't delete vehicle: {}", e);
|
||||
Err(e)
|
||||
|
|
Loading…
Reference in New Issue