Skip to content

Commit

Permalink
Bug 792157 - Cannot create account with different currency
Browse files Browse the repository at this point in the history
Restore force-insert logic that had gotten lost in the C++ conversion.
  • Loading branch information
jralls committed Feb 21, 2018
1 parent c58b002 commit a4399ee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libgnucash/backend/sql/gnc-commodity-sql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ GncSqlCommodityBackend::commit (GncSqlBackend* sql_be, QofInstance* inst)
g_return_val_if_fail (sql_be != NULL, FALSE);
g_return_val_if_fail (inst != NULL, FALSE);
g_return_val_if_fail (GNC_IS_COMMODITY (inst), FALSE);

return do_commit_commodity (sql_be, inst, FALSE);
auto in_be = instance_in_db(sql_be, inst);
return do_commit_commodity (sql_be, inst, !in_be);
}

/* ----------------------------------------------------------------- */
Expand Down
2 changes: 2 additions & 0 deletions libgnucash/backend/sql/gnc-sql-backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,8 @@ GncSqlBackend::object_in_db (const char* table_name, QofIdTypeConst obj_name,

/* WHERE */
PairVec values{get_object_values(obj_name, pObject, table)};
/* We want only the first item in the table, which should be the PK. */
values.resize(1);
stmt->add_where_cond(obj_name, values);
auto result = execute_select_statement (stmt);
return (result != nullptr && result->size() > 0);
Expand Down

0 comments on commit a4399ee

Please sign in to comment.