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.
- 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
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.
Where it was required only to pass down to the CT_TIMESPEC specialization
of template<GncSqlObjectType Type>GncSqlColumnTableEntryImpl::add_to_query().
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.
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.
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).
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.
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.
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.