Skip to content

Commit 6bb97b5

Browse files
committed
shortened some code.
1 parent e4bc281 commit 6bb97b5

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

postgres-rest/src/queries/insert_into_table.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,9 @@ fn execute_insert<'a>(
217217
insert_statement_tokens.push(&values_params_str);
218218

219219
// generate the ON CONFLICT string
220-
let conflict_clause = match generate_conflict_str(&params, &columns) {
221-
Some(conflict_str) => conflict_str,
222-
None => "".to_string(),
223-
};
224-
if conflict_clause != "" {
220+
let conflict_clause;
221+
if let Some(conflict_str) = generate_conflict_str(&params, &columns) {
222+
conflict_clause = conflict_str;
225223
insert_statement_tokens.push(&conflict_clause);
226224
}
227225

postgres-rest/src/queries/update_table_rows.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -239,16 +239,14 @@ fn build_update_statement(
239239
}
240240

241241
// FROM string
242-
let from_tables_str = if !fks.is_empty() {
243-
ForeignKeyReference::join_foreign_key_references(
242+
let from_tables_str;
243+
if !fks.is_empty() {
244+
from_tables_str = ForeignKeyReference::join_foreign_key_references(
244245
&fks,
245246
|(_, _, referred_table, _)| referred_table.to_string(),
246247
", ",
247-
)
248-
} else {
249-
"".to_string()
250-
};
251-
if &from_tables_str != "" {
248+
);
249+
252250
query_str_arr.push(" FROM ");
253251
query_str_arr.push(&from_tables_str);
254252
}

0 commit comments

Comments
 (0)