Merge branch 'maint'

This commit is contained in:
John Ralls
2020-06-20 15:36:58 -07:00
2 changed files with 19 additions and 5 deletions

View File

@@ -72,6 +72,7 @@ static QofLogModule log_module = G_LOG_DOMAIN;
using StrVec = std::vector<std::string>; using StrVec = std::vector<std::string>;
static std::string empty_string{};
static EntryVec version_table static EntryVec version_table
{ {
gnc_sql_make_table_entry<CT_STRING>( gnc_sql_make_table_entry<CT_STRING>(
@@ -99,7 +100,7 @@ GncSqlBackend::connect(GncSqlConnection *conn) noexcept
GncSqlStatementPtr GncSqlStatementPtr
GncSqlBackend::create_statement_from_sql(const std::string& str) const noexcept GncSqlBackend::create_statement_from_sql(const std::string& str) const noexcept
{ {
auto stmt = m_conn->create_statement_from_sql(str); auto stmt = m_conn ? m_conn->create_statement_from_sql(str) : nullptr;
if (stmt == nullptr) if (stmt == nullptr)
{ {
PERR ("SQL error: %s\n", str.c_str()); PERR ("SQL error: %s\n", str.c_str());
@@ -111,7 +112,7 @@ GncSqlBackend::create_statement_from_sql(const std::string& str) const noexcept
GncSqlResultPtr GncSqlResultPtr
GncSqlBackend::execute_select_statement(const GncSqlStatementPtr& stmt) const noexcept GncSqlBackend::execute_select_statement(const GncSqlStatementPtr& stmt) const noexcept
{ {
auto result = m_conn->execute_select_statement(stmt); auto result = m_conn ? m_conn->execute_select_statement(stmt) : nullptr;
if (result == nullptr) if (result == nullptr)
{ {
PERR ("SQL error: %s\n", stmt->to_sql()); PERR ("SQL error: %s\n", stmt->to_sql());
@@ -123,7 +124,7 @@ GncSqlBackend::execute_select_statement(const GncSqlStatementPtr& stmt) const no
int int
GncSqlBackend::execute_nonselect_statement(const GncSqlStatementPtr& stmt) const noexcept GncSqlBackend::execute_nonselect_statement(const GncSqlStatementPtr& stmt) const noexcept
{ {
auto result = m_conn->execute_nonselect_statement(stmt); int result = m_conn ? m_conn->execute_nonselect_statement(stmt) : -1;
if (result == -1) if (result == -1)
{ {
PERR ("SQL error: %s\n", stmt->to_sql()); PERR ("SQL error: %s\n", stmt->to_sql());
@@ -135,6 +136,9 @@ GncSqlBackend::execute_nonselect_statement(const GncSqlStatementPtr& stmt) const
std::string std::string
GncSqlBackend::quote_string(const std::string& str) const noexcept GncSqlBackend::quote_string(const std::string& str) const noexcept
{ {
g_return_val_if_fail (m_conn != nullptr, empty_string);
if (!m_conn)
return empty_string;
return m_conn->quote_string(str); return m_conn->quote_string(str);
} }
@@ -142,8 +146,9 @@ bool
GncSqlBackend::create_table(const std::string& table_name, GncSqlBackend::create_table(const std::string& table_name,
const EntryVec& col_table) const noexcept const EntryVec& col_table) const noexcept
{ {
g_return_val_if_fail (m_conn != nullptr, false);
ColVec info_vec; ColVec info_vec;
gboolean ok = FALSE;
for (auto const& table_row : col_table) for (auto const& table_row : col_table)
{ {
@@ -167,6 +172,7 @@ GncSqlBackend::create_index(const std::string& index_name,
const std::string& table_name, const std::string& table_name,
const EntryVec& col_table) const noexcept const EntryVec& col_table) const noexcept
{ {
g_return_val_if_fail (m_conn != nullptr, false);
return m_conn->create_index(index_name, table_name, col_table); return m_conn->create_index(index_name, table_name, col_table);
} }
@@ -174,6 +180,8 @@ bool
GncSqlBackend::add_columns_to_table(const std::string& table_name, GncSqlBackend::add_columns_to_table(const std::string& table_name,
const EntryVec& col_table) const noexcept const EntryVec& col_table) const noexcept
{ {
g_return_val_if_fail (m_conn != nullptr, false);
ColVec info_vec; ColVec info_vec;
for (auto const& table_row : col_table) for (auto const& table_row : col_table)
@@ -451,6 +459,7 @@ void
GncSqlBackend::sync(QofBook* book) GncSqlBackend::sync(QofBook* book)
{ {
g_return_if_fail (book != NULL); g_return_if_fail (book != NULL);
g_return_if_fail (m_conn != nullptr);
reset_version_info(); reset_version_info();
ENTER ("book=%p, sql_be->book=%p", book, m_book); ENTER ("book=%p, sql_be->book=%p", book, m_book);
@@ -560,6 +569,7 @@ GncSqlBackend::commit (QofInstance* inst)
gboolean is_infant; gboolean is_infant;
g_return_if_fail (inst != NULL); g_return_if_fail (inst != NULL);
g_return_if_fail (m_conn != nullptr);
if (qof_book_is_readonly(m_book)) if (qof_book_is_readonly(m_book))
{ {
@@ -650,7 +660,7 @@ GncSqlBackend::commit (QofInstance* inst)
void void
GncSqlBackend::init_version_info() noexcept GncSqlBackend::init_version_info() noexcept
{ {
g_return_if_fail (m_conn != nullptr);
if (m_conn->does_table_exist (VERSION_TABLE_NAME)) if (m_conn->does_table_exist (VERSION_TABLE_NAME))
{ {
std::string sql {"SELECT * FROM "}; std::string sql {"SELECT * FROM "};

View File

@@ -19399,6 +19399,10 @@ msgstr ""
msgid "Statement Date is after today" msgid "Statement Date is after today"
msgstr "Дата виписки у майбутньому щодо поточної" msgstr "Дата виписки у майбутньому щодо поточної"
#: gnucash/gtkbuilder/window-reconcile.glade:243
msgid "Statement Date is after today"
msgstr "Дата виписки у майбутньому щодо поточної"
#: gnucash/html/gnc-html-webkit1.c:80 gnucash/html/gnc-html-webkit2.c:91 #: gnucash/html/gnc-html-webkit1.c:80 gnucash/html/gnc-html-webkit2.c:91
msgid "Not found" msgid "Not found"
msgstr "Не знайдено" msgstr "Не знайдено"