Commit Graph

87 Commits

Author SHA1 Message Date
Geert Janssens
9d5712ef09 Use same 'force' logic sequence for sqlite and other dbs 2018-07-06 22:32:01 +02:00
Geert Janssens
875781847a Bug 796724 - Can't overwrite gnucash DB on MariaDB 2018-07-06 22:30:15 +02:00
Geert Janssens
9ab06bc9b3 Bug 789594 - Unable to overwrite sqlite3 database file 2018-07-05 22:41:56 +02:00
Geert Janssens
240c4bd2cf Whitespace cosmetics 2018-07-05 22:41:56 +02:00
John Ralls
f7ed46a35b Bug 796248 - Editing Scheduled Transaction, take 2.
In addition to not begining to edit already-loaded transactions,
don't try to load splits that are already loaded. It shouldn't
be possible to load a transaction without also loading its splits.
2018-06-26 15:04:23 -07:00
John Ralls
4e04f6e51d Don't warn about an invalid date if it's just an empty column. 2018-06-26 15:00:51 -07:00
John Ralls
1e6627c4c5 [DBI Backend] Init and finalize the backend in setup and teardown.
Xcode 9's clang creates a separate dbi_instance for each test and so
each one needs to be initialized during its setup and finalized at
teardown.
2018-06-23 17:35:42 -07:00
Geert Janssens
a438a59513 Bug 795944 - Cannot store change to Business Suppliers data
The underlying problem was that the vendor object remained in infant state
That confused the backend code so it used an sql INSERT statement instead
of an UPDATE statement to write back the changes. As the object already
existed in the db this would fail.
The fix is to ensure the object doesn't remain in infant state during
sql loading. See the bug report for a more detailed explanation.
2018-06-23 13:15:46 +02:00
John Ralls
f144a8deb7 Revert "Bug 796248 - Editing Scheduled Transaction"
This reverts commit ffe6044cd6.
It breaks loading splits on transactions that have already
been loaded.
2018-06-22 10:14:21 -07:00
John Ralls
696277bbf6 New clang error enforces virtual destructors. 2018-06-22 09:09:33 -07:00
John Ralls
ffe6044cd6 Bug 796248 - Editing Scheduled Transaction
An extra XaccTransBeginEdit, never committed, for transactions that
the backend tried to load when they were already there. That made
the register think that something else had it open.
2018-06-12 15:49:28 -07:00
John Ralls
c8861d4666 Bug 795276 - Invalid date on price stops file from being parsed.
Instead of reporting an error and declining to load the file (XML)
or failing to enter a value (SQL) when a bad date is found in the
database, use a 0 time stamp (1970-01-01 00:00:00 UTC). Adds a warning
in SQL backends; there was one already in XML.
2018-06-12 14:56:27 -07:00
John Ralls
333a14c0fd Fix ubuntu build failure.
%$^%$ C++11 initializer list behavior.
2018-06-02 17:57:42 -07:00
John Ralls
3b3074c28d Bug 796117 - Connecting 3.1 to an existing mysql db drops all data
Provide a backup recovery function that instead of dropping primaries
and restoring backups merges the primaries and backups. This should
handle a worst-case safe-save failure where the backup tables don't
have a complete set of rows for some reason.
2018-06-02 16:21:49 -07:00
John Ralls
f8045b2735 A wee bit of C++ style. 2018-06-02 16:21:05 -07:00
John Ralls
537fd995a3 Ensure full precision of doubles is saved to SQL.
std::iostream's operator<<(double) uses only 6 digits of precision
by default. We want 12 digits when saving.
2018-06-02 16:20:36 -07:00
John Ralls
9db60ca63c Make float database operations more consistent.
We don't use floats in GnuCash, we use doubles (and those as little as
possible), but dbd-sqlite3 is broken in that it stores only floats.
Simply casting floats to doubles introduces bogus additional digits
that can cause round-trip tests to fail. Instead convert floats to
doubles by multiplying by 10E6, rounding, then dividing by 10E6.
2018-06-02 16:16:41 -07:00
John Ralls
3e052e8dac [DBI Backend] Rework backup-table management.
Removes a public function, GncDbiSqlConnection::table_manage_backup that
should have been private in the first place.

Better encapsulates table renames and drops with private functions and
handles cases where there exist some primary tables and some backup tables.
2018-06-01 14:50:41 -07:00
John Ralls
e23769f078 [DBI Backend] If there's a set error value use that to set the backend error. 2018-06-01 14:13:11 -07:00
John Ralls
f504e39d78 Correct the type of error variables.
C++ doesn't like interchanging enums and ints.
2018-06-01 14:13:11 -07:00
John Ralls
464fdeeb26 [DBI Backend] Remove unused TableOpTypes. 2018-06-01 14:13:10 -07:00
John Ralls
243bf8afce Bug 796369 - Notes lost or perhaps just not displaying when using...
SQLite backend.

Release Note: This bug caused data loss if you saved your SQLite3
database to a different file or database.

The problem is that in SQLite3 (though not in MySQL or PgSQL) the
subquery ((SELECT DISTINCT guid FROM transactions)) (note the double
parentheses) returns only the first guid in the subquery's results.

Some transactions are loaded by special queries and those queries are
also used to retrieve the transaction's slots so they weren't affected.
2018-05-25 12:58:39 -07:00
gnucash-dev
8b3a874418 Fix typo 2018-05-04 10:04:52 -07:00
Geert Janssens
a9f35ed7ae Lowercase cmake commands
A huge bikeshed fest but it distracted me enough to do it anyway.
2018-05-03 23:18:15 +02:00
Geert Janssens
b761b5a0dc Bug 795377 - Reads and saves Gnucash 2.6.19 XML file, then can't reread it, due to bad date in old file
This commit contains another round of cleanups in the
timespec to time64 conversion. There were a number of
false assumptions that time64 = 0 would be a bad date
in the xml parser. This commit corrects enough of them to
eliminate the bug. Further cleanup is probably advised but
can be done at a later stage.
2018-04-28 12:19:28 +02:00
Geert Janssens
c71204628d Bug 795031 - 3.0 Crashes on loading when opening 2.6.19 file 2018-04-26 23:06:36 +02:00
John Ralls
cad6bb4272 Bug 792105 - Startup takes several minutes, take two.
First, remove the unnecessary locale push & pop on <CT_TIME64>load.

Second, the registry accesses were caused by using g_win32_get_locale
to convert the Microsoft locale strings to POSIX ones. We don't care
what kind of string we get as long as we can pass it back to setlocale,
so remove that.

Third, gnc_push/pop_locale were used only in backend/dbi in a
very limited way and did much more than was necessary, so
convert them to C++ inlines in gnc-backend-dbi.hpp that does
only what we need them to.
2018-04-17 16:32:45 -07:00
John Ralls
39aecb7610 Bug 794936 - 3.0 does not open previously saved sqlite3 files...
properly - corrupted business data

Turned out to be a pointer/value mismatch between <CT_NUMERIC>load()
and most of the setter functions, so the address was getting set
as the value.
2018-04-17 16:32:44 -07:00
Geert Janssens
3138229cf6 A few whitespace fixups 2018-04-17 23:04:21 +02:00
Geert Janssens
06db9bcf2b Fix crash when loading sql book with posted transactions
This crash started to appear as of commit 80dbb9940b 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.
2018-04-17 23:04:21 +02:00
Geert Janssens
80dbb9940b Fix a couple of warnings introduced by commit 01420adb99
In addition make the code really use an inner join if no additional conditions are set
which gives better performance on at least postgresql
2018-04-17 19:45:39 +02:00
John Ralls
4ba77f7b09 Remove another gnc_pop_locale(). 2018-04-14 13:11:23 -07:00
John Ralls
a04fd573ef Bug 792105 - Startup takes several minutes
set/get_locale are apparently very expensive on Mingw64, and setting
the C locale for extracting a string is unnecessary.

Unfortunately the released version of libdbi still uses strtod so
setting the C locale *is* still necessary for retrieving floats
and doubles and for passing queries.

Thanks to Mkubat for the diagnosis.
2018-04-14 12:38:04 -07:00
John Ralls
01420adb99 Bug 772776 - VERY large queries (over 11000 fields in IN clause) slow...
down GnuCash

Replace with joins or subqueries. Affords a 20% speedup on Windows.
2018-04-14 10:18:01 -07:00
John Ralls
e90a662a20 Use subquery instead of instancevec GncSqlTransBackend::load_all. 2018-04-14 10:18:01 -07:00
John Ralls
b739661171 Remove functions marked G_UNUSED.
More noise reduction.
2018-04-14 10:18:01 -07:00
John Ralls
9b64357427 Remove LOAD_TRANSACTIONS_AS_NEEDED from SQL backend.
We're not ready for that and until we are it's just noise.
2018-04-14 10:18:01 -07:00
John Ralls
e4d0ad9dda Reduce use of gnc_sql_slots_load_for_instancevec. 2018-04-14 10:18:01 -07:00
Bill Nottingham
434dd9520c Adjust catch syntax to avoid GCC8 warnings. 2018-04-03 22:02:44 -04:00
Geert Janssens
7271ce3dee Add feature kvp frame to the dbi test file 2018-03-30 19:02:57 +02:00
Geert Janssens
152277274f Fix slot loading in sql backend
Be smarter about what is path and key for each slot.
Instead of assuming a slash is always a path separator (first attempt
on unstable) or never a separator (second attempt),
track the parent path while loading kvp slots from the db
and deduce the slot's name by substracting this parent path.
2018-03-30 19:02:57 +02:00
John Ralls
8fe2cb6fa8 Fix date corruption in SQL load.
Four date elements were affected: GncEntry::date, GncEntry::date_entered,
GncInvoice::opened, and GncInvoice::posted. The problem arose during the
cleansing of Timespec from the reports; the setter functions for those
elements were converted to time64 but no provision was made to the SQL
backend to pass them time64 instead of Timespec*.

This commit adds a new column type, CT_TIME64, and changes the column
types for those elements to CT_TIME64.
2018-03-16 16:47:11 -07:00
John Ralls
e5561bd7ab Fix lost Bayesian matches in SQL backend.
The import-map-bayes uses a three-part key that uses the same delimiter
as a path and the SQL backend was throwing away everything except the
account guid.

Added more slot types including import-map-bayes ones to the test xml
file to help debug this and to catch it in the future.

Also don't pass std::string.c_str() to a std::vector<std::string>
constructor, just pass the string.
2018-03-16 13:59:04 -07:00
John Ralls
74d94650ed Avoid crash when committing a date outside of the valid range
Insert a NULL in its place.
2018-03-15 16:28:01 -07:00
John Ralls
a4399ee732 Bug 792157 - Cannot create account with different currency
Restore force-insert logic that had gotten lost in the C++ conversion.
2018-02-20 17:32:22 -08:00
John Ralls
78705dc8be Bug 792833 - User specifies source of 'num' field'; either...
transaction number or split action (requires at least GnuCash 2.5.0)

Strip leading delimiters from KVP keys when reading them from the
database. Leading delimiters are incorrectly included in databases
created with GnuCash 2.6.x.
2018-02-20 12:02:38 -08:00
Geert Janssens
00396db560 Remove the .in extension from test-real-data.sh and stop configuring it for autotools
We have dropped support for autotools and cmake invokes this script using /bin/bash <script>
So the exact shebang value is not relevant any more
2018-01-26 18:26:06 +01:00
Geert Janssens
0f4a72b49f Remove unused file 2018-01-26 18:26:06 +01:00
John Ralls
74ddb671e4 Merge Chris Lam's and Aaron Laws's branch 'time64-ftw' into unstable. 2018-01-20 12:40:32 -08:00
John Ralls
6ffb77de20 Merge branch Rob Gowin's 'bye_bye_autotools' into unstable. 2018-01-18 12:02:56 -08:00