Commit Graph

17939 Commits

Author SHA1 Message Date
Geert Janssens
96c22f54a3 Show empty business splits in lot viewer 2016-11-12 11:06:25 +01:00
Geert Janssens
254b4fbc2f Check more splits while running check & repair on business accounts
In addition, speed up the process a bit by already deleting empty splits as soon as they're encountered
2016-11-12 11:06:23 +01:00
Geert Janssens
a9c624bfad Business check & repair - correct lot invoice state
There have been situations where a lot refered to an invoice while
it doesn't actually contain splits for that invoice (any more).
The new code corrects this by removing the invoice reference from the lot.
Also if the lot and its splits don't agree on the invoice they belong to
set the lot invoice to whatever the splits indicate.
2016-11-12 11:06:22 +01:00
Geert Janssens
396117eec9 Various small improvements to check & repair on business accounts
- don't attempt to merge splits that belong to an invoice transaction. These splits are managed by the business code.
- lot link cleanup can leave empty splits, remove these as well
2016-11-12 11:06:20 +01:00
Geert Janssens
d52f44a8c7 When juggling business splits while scrubbing set both value and amount
With only value there were several warnings in the log file during scrubbing
2016-11-12 11:06:18 +01:00
Geert Janssens
0bcd30301e Update progress bar while running Check & Repair
Not complete - should still be added for check & repair invoked from a split register
2016-11-12 11:06:17 +01:00
Geert Janssens
673888dee7 Remove lot from account while deleting the lot
There was no way the account was informed about the lot being deleted.
This was resulting into invalid lot lists in an account while scrubbing.
Which would bomb at later stages like when re-running check & repair or
opening the lot viewer. Also saving would report a number of critical messages
about invalid objects, but these didn't result in a segfault.
2016-11-12 11:06:14 +01:00
John Ralls
32c4d14588 Ensure that the Namespace combo box is initialized to a valid iter.
Thanks to David T. for noticing that it wasn't.
2016-11-10 13:56:09 -08:00
John Ralls
ada3a31216 Fix DBI crash when URL lacks user and password. 2016-11-07 12:48:52 -08:00
John Ralls
c470d006ee Remove no-longer-necessary GncSqlBackend parameter.
Where it was required only to pass down to the CT_TIMESPEC specialization
of template<GncSqlObjectType Type>GncSqlColumnTableEntryImpl::add_to_query().
2016-11-07 12:48:51 -08:00
John Ralls
10b006fdc1 Replace GncSqlBackend::time64_to_string() with GncDateTime::format_zulu().
The primary motivation was to enable removing the sql_be parameter from
get_object_values and all of the templates it calls for the sole purpose
of using a customized per-server time output format (next commit). All
known sql servers/libraries can ingest GMT in ISO form (yyyy-mm-dd hh:mm:ss)
so there's no reason not to use a single standard format.

This has the secondary benefit of also removing an ugly character-by-character
formatting routine.
2016-11-07 12:48:50 -08:00
John Ralls
db719191a1 New function GncDateTime::format_zulu(), makes time string in GMT.
Required to ensure that date-times stored in SQL backend are in GMT for
backward compatibility.
2016-11-07 12:48:50 -08:00
John Ralls
ee0e61a07e Replace C API with C++ API for functions used by GncSqlDbiBackend.
Since these are now parent-class member functions they can be called
directly from dbi_be without any casting gymnastics.

Also: Move the GncSqlObjectBackend registry to its own class, a private
member of GncSqlBackend. This eliminates a static variable in gnc-backend-sql.cpp
and allows the GncSqlBackend::ObjectRegistry constructor to insert all of
the backends into the list, eliminating gnc_sql_init() and all of the
gnc_sql_init_foo_handler() functions. The cost of this is that the objects
are now created on the free store instead of the text segment.

Because the object backends are created at GncSqlBackend construction
there is now a GncSqlBookBackend in the registry and the second error
message in test_gnc_sql_commit_edit is no longer emitted; instead, the
object is properly committed.
2016-11-07 12:48:49 -08:00
John Ralls
b2a644c29d Separate SQL backend classes into their own header and source files.
And adjust includes accordingly.
2016-11-07 12:48:48 -08:00
John Ralls
4ae5abf83b Distinguish variables of various backend types by naming.
QofBackend* qof_be, GncSqlBackend* sql_be, and GncDbiBackend* dbi_be.\nRequested by Geert Janssens.
2016-11-07 12:48:47 -08:00
John Ralls
d1b406d8db Allow PRId64 & PRIu64 to work on MingGW in gnc-backend-dbi.cpp. 2016-11-07 12:47:34 -08:00
John Ralls
472b585feb Interim merge of c++-backend to expose C++ interface. 2016-10-29 13:16:29 -07:00
John Ralls
b8024fa9ea Fix review comment errors. 2016-10-29 12:40:57 -07:00
John Ralls
00880cd8f5 Fix another initializer list error. 2016-10-29 12:05:47 -07:00
John Ralls
70c803d6aa Fix unsigned-signed comparison mismatch. 2016-10-28 13:03:56 -07:00
John Ralls
afb57d0e7b Initialize a variable to appease travis-ci. 2016-10-28 12:31:49 -07:00
John Ralls
0bc35eb3e2 Fix two C++11 initializer list errors. 2016-10-28 11:38:29 -07:00
John Ralls
10ff71b29a Fix passing std::string to PWARN. 2016-10-28 10:33:54 -07:00
John Ralls
0baff455a2 Bug 769115 - db name isn't escaped well
More like at all, but it's supposed to be quoted rather than
escaped.
dbi_conn_quote_string() doesn't work well for database names,
so we do it directly. libdbi is also inconsistent about needing
quotes: They're required by mysql in SQL commands, and libdbi
requires them for internal commands that it turns into SQL
(e.g. db_conn_get_table_list) but not others (e.g dbi_conn_set_option).
2016-10-28 10:33:54 -07:00
John Ralls
7ff6e51a72 Use GncDbiProvider::get_table_list instead of calling out to libdbi.
GncDbiProvider can figure out the dbname for itself so change the
function signature to replace dbname with a particular table to
search for. Pass an empty string ("" works) to get the full list.
2016-10-28 10:33:54 -07:00
John Ralls
02d173d2e7 Replace g_str functions in dbi_library_test with std::stringstream. 2016-10-28 10:33:54 -07:00
John Ralls
451f3ffe4d DBI: Convert all of the gchar to char, remove a few gratuitous g_funcs.
Except where we're explicitly using other GLib functions.
2016-10-28 10:33:54 -07:00
John Ralls
5065bce45c Combine Postgres and MySql gnc_dbi_session_begin into a single template. 2016-10-28 10:33:53 -07:00
John Ralls
c141711425 Move creation of the provider to GncDbiSqlConnection's constructor.
Making GncDbiProviderImpl private to GncDbiSqlConnection.
2016-10-28 10:33:53 -07:00
John Ralls
5d38c7a729 Make conn_setup and the error handler functions templates on DbType. 2016-10-28 10:33:53 -07:00
John Ralls
314a5e10c2 Make gnc_lock_database a GncDbiSqlConnection member function.
Called from the constructor, so effective RAII with unlock_database called
from the destructor.
2016-10-28 10:33:53 -07:00
John Ralls
00e0a6e8b6 Change parameter of save_may_clobber_data from QofBackend to dbi_conn.
It actually needs the dbi_conn and that's known to its caller. Plus,
the backend's conn parameter hasn't actually been set so it was somewhat
coincidental that it worked.
2016-10-28 10:33:53 -07:00
John Ralls
fc47b63265 Templatize the session_begin functions and new_backend().
Thus removing the need for specializations of
QofDbiBackendProvider::create_backend().
2016-10-28 10:33:53 -07:00
John Ralls
61beed5686 Make sure that all of the GncDbiProviderImpl functions are in the right file.
Also merge create_table_ddl back into the only function that used it.
2016-10-28 10:33:53 -07:00
John Ralls
31c73a141e Extract functions conn_setup and create_database. 2016-10-28 10:33:53 -07:00
John Ralls
37d4257336 Extract-function conn_test_dbi_library.
Renaming the previous so-named function dbi_library_test.
2016-10-28 10:33:53 -07:00
John Ralls
5074bd590f Don't leak the quoted string returned from dbi_conn_quote_string_copy. 2016-10-28 10:33:53 -07:00
John Ralls
b38be9fe20 Get rid of gotos.
By replacing all of the char*s on the heap to std::strings, mostly in
a new UriString struct. Also lets us simplify the call to
set_standard_connection_options.
2016-10-28 10:33:53 -07:00
John Ralls
d8556ca7b5 Reformat adjust_sql_options a bit to reduce nesting. 2016-10-28 10:33:52 -07:00
John Ralls
431b704c92 Abstract setting database string-value options to function set_options. 2016-10-28 10:33:52 -07:00
John Ralls
ccc1cc49ab Separate DBI classes into their own files. 2016-10-28 10:33:52 -07:00
John Ralls
c2082bea99 Convert upgrade_table to member, remove some convenience functions.
To wit, gnc_sql_execute_select_sql, gnc_sql_execute_nonselect_sql,
gnc_sql_create_temp_table, and gnc_sql_create_select_statement.
2016-10-28 10:33:52 -07:00
John Ralls
54acef27c2 Remove a bunch of free functions already implemented as GncSqlBackend members. 2016-10-28 10:33:52 -07:00
John Ralls
a303ae688a Remove some GList and GSList uses from tests. 2016-10-28 10:33:52 -07:00
John Ralls
4b62deee42 Rework gnc_sql_append_guid_list_to_sql to eliminate GString and GList.
Which in turn forced rework of its users since the GString and GList were
passed-in parameters.
2016-10-28 10:33:52 -07:00
John Ralls
cb464da599 Replace GHashTable in GncSqlConnection with a std::vector. 2016-10-28 10:33:52 -07:00
John Ralls
885470b3e7 Replace std::vector<std::string> with StrVec. 2016-10-28 10:33:52 -07:00
John Ralls
d1fd223f9f Make conn_table_operation and add_columns_ddl members of GncDbiSqlConnection.
So they don't need to be friends.
2016-10-28 10:33:51 -07:00
John Ralls
6f67e2dd1a Convert GncSqlBackend and GncDbiBackend into a class hierarchy.
This is a rather complex change, because it also begins to separate the
responsibilities of the backends and GncSqlConnection.
2016-10-28 10:33:51 -07:00
John Ralls
d106346316 Minimally document GncDbiResult. 2016-10-28 10:33:51 -07:00