Browse Source
Switch error handling to ? operator instead of explicit handling.
pull/812/head
Michael Powers
5 years ago
No known key found for this signature in database
GPG Key ID: 81A665ADB3123BD
1 changed files with
2 additions and
5 deletions
-
src/db/models/two_factor.rs
|
@ -76,12 +76,9 @@ impl TwoFactor { |
|
|
// We need to make sure we're not going to violate the unique constraint on user_uuid and atype.
|
|
|
// We need to make sure we're not going to violate the unique constraint on user_uuid and atype.
|
|
|
// This happens automatically on other DBMS backends due to replace_into(). PostgreSQL does
|
|
|
// This happens automatically on other DBMS backends due to replace_into(). PostgreSQL does
|
|
|
// not support multiple constraints on ON CONFLICT clauses.
|
|
|
// not support multiple constraints on ON CONFLICT clauses.
|
|
|
let result: EmptyResult = diesel::delete(twofactor::table.filter(twofactor::user_uuid.eq(&self.user_uuid)).filter(twofactor::atype.eq(&self.atype))) |
|
|
diesel::delete(twofactor::table.filter(twofactor::user_uuid.eq(&self.user_uuid)).filter(twofactor::atype.eq(&self.atype))) |
|
|
.execute(&**conn) |
|
|
.execute(&**conn) |
|
|
.map_res("Error deleting twofactor for insert"); |
|
|
.map_res("Error deleting twofactor for insert")?; |
|
|
if result.is_err() { |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
diesel::insert_into(twofactor::table) |
|
|
diesel::insert_into(twofactor::table) |
|
|
.values(self) |
|
|
.values(self) |
|
|