gnucash maint: Multiple changes pushed
Geert Janssens
gjanssens at code.gnucash.org
Tue Apr 17 17:06:11 EDT 2018
Updated via https://github.com/Gnucash/gnucash/commit/3138229c (commit)
via https://github.com/Gnucash/gnucash/commit/06db9bcf (commit)
from https://github.com/Gnucash/gnucash/commit/51d1bc77 (commit)
commit 3138229cf6c2e097731cc10b010b5035304fbf6f
Author: Geert Janssens <geert at kobaltwit.be>
Date: Tue Apr 17 23:04:18 2018 +0200
A few whitespace fixups
diff --git a/libgnucash/backend/sql/gnc-transaction-sql.cpp b/libgnucash/backend/sql/gnc-transaction-sql.cpp
index 5aa2310..c7640b9 100644
--- a/libgnucash/backend/sql/gnc-transaction-sql.cpp
+++ b/libgnucash/backend/sql/gnc-transaction-sql.cpp
@@ -259,13 +259,13 @@ load_splits_for_transactions (GncSqlBackend* sql_be, std::string selector)
std::string sql("SELECT ");
if (selector.empty())
{
- sql += SPLIT_TABLE ".* FROM " SPLIT_TABLE " INNER JOIN "
- TRANSACTION_TABLE " ON " SPLIT_TABLE "." + sskey + " = "
- TRANSACTION_TABLE "." + tpkey;
- selector = "(SELECT DISTINCT " + tpkey + " FROM " TRANSACTION_TABLE ")";
+ sql += SPLIT_TABLE ".* FROM " SPLIT_TABLE " INNER JOIN "
+ TRANSACTION_TABLE " ON " SPLIT_TABLE "." + sskey + " = "
+ TRANSACTION_TABLE "." + tpkey;
+ selector = "(SELECT DISTINCT " + tpkey + " FROM " TRANSACTION_TABLE ")";
}
else
- sql += " * FROM " SPLIT_TABLE " WHERE " + sskey + " IN " + selector;
+ sql += " * FROM " SPLIT_TABLE " WHERE " + sskey + " IN " + selector;
// Execute the query and load the splits
auto stmt = sql_be->create_statement_from_sql(sql);
@@ -276,7 +276,7 @@ load_splits_for_transactions (GncSqlBackend* sql_be, std::string selector)
sql = "SELECT DISTINCT ";
sql += spkey + " FROM " SPLIT_TABLE " WHERE " + sskey + " IN " + selector;
gnc_sql_slots_load_for_sql_subquery(sql_be, sql,
- (BookLookupFn)xaccSplitLookup);
+ (BookLookupFn)xaccSplitLookup);
}
static Transaction*
@@ -350,17 +350,17 @@ query_transactions (GncSqlBackend* sql_be, std::string selector)
std::string sql("SELECT * FROM " TRANSACTION_TABLE);
if (!selector.empty() && selector[0] == '(')
- sql += " WHERE " + tpkey + " IN " + selector;
+ sql += " WHERE " + tpkey + " IN " + selector;
else if (!selector.empty()) // plain condition
- sql += " WHERE " + selector;
+ sql += " WHERE " + selector;
auto stmt = sql_be->create_statement_from_sql(sql);
auto result = sql_be->execute_select_statement(stmt);
if (result->begin() == result->end())
{
- PINFO("Query %s returned no results", sql.c_str());
+ PINFO("Query %s returned no results", sql.c_str());
return;
}
-
+
Transaction* tx;
// Load the transactions
@@ -379,7 +379,7 @@ query_transactions (GncSqlBackend* sql_be, std::string selector)
// Load all splits and slots for the transactions
if (!instances.empty())
{
- const std::string tpkey(tx_col_table[0]->name());
+ const std::string tpkey(tx_col_table[0]->name());
if (!selector.empty() && (selector[0] != '('))
{
auto tselector = std::string ("(SELECT DISTINCT ");
commit 06db9bcf2b68c9477ea3a75ded16c27597deadd0
Author: Geert Janssens <geert at kobaltwit.be>
Date: Tue Apr 17 23:03:31 2018 +0200
Fix crash when loading sql book with posted transactions
This crash started to appear as of commit 80dbb9940b77d because the sequence
of split loading has changed as a result of the query optimizations.
Invoice transactions get loaded before the general transaction loading happens.
However because of this, when an invoice transaction was encountered again
during general transaction loading, it was (correctly) not created again
AND (incorrectly) not opened for subsequent editing. This caused
an assert to fail when the splits for this transaction are loaded
shortly afterwards. The solution is simply to ensure all transactions
are opened for editing during the general transaction loading call.
diff --git a/libgnucash/backend/sql/gnc-transaction-sql.cpp b/libgnucash/backend/sql/gnc-transaction-sql.cpp
index 9457a73..5aa2310 100644
--- a/libgnucash/backend/sql/gnc-transaction-sql.cpp
+++ b/libgnucash/backend/sql/gnc-transaction-sql.cpp
@@ -293,9 +293,11 @@ load_single_tx (GncSqlBackend* sql_be, GncSqlRow& row)
tx_guid = *guid;
// Don't overwrite the transaction if it's already been loaded (and possibly modified).
+ // However increase the edit level, it may be modified while loading its splits
pTx = xaccTransLookup (&tx_guid, sql_be->book());
if (pTx != NULL)
{
+ xaccTransBeginEdit (pTx);
return NULL;
}
Summary of changes:
libgnucash/backend/sql/gnc-transaction-sql.cpp | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
More information about the gnucash-changes
mailing list