Commit Graph

95 Commits

Author SHA1 Message Date
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
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
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
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
c71204628d Bug 795031 - 3.0 Crashes on loading when opening 2.6.19 file 2018-04-26 23:06:36 +02: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
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
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
John Ralls
6ffb77de20 Merge branch Rob Gowin's 'bye_bye_autotools' into unstable. 2018-01-18 12:02:56 -08:00
John Ralls
8900b19da3 Bug 790845 - 2.7.3: massive test failures on some architectures (reopened).
Fix some test failures caused by erroneous size assumptions.
2018-01-14 16:31:22 -08:00
Rob Gowin
54ac7f23e0 Remove Autotools 2018-01-13 12:52:57 -06:00
John Ralls
91727525b9 Enforce -Werror on C++ files and fix resulting errors. 2017-12-26 15:18:43 -08:00
lmat
5636afc4a2 Kvp no longer parses entries looking for delimiters 2017-12-21 07:39:32 -05:00
lmat
34e0d6cfa0 kvp frame to template and correcting failure macro
The template avoids the need to cast to and from void*, and adds flexibility to
the targeted function's signature.

test-stuff.h defines a macro, "failure" which is used as an identifier
in the standard IO library, so I moved any inclusion of test-stuff.h to
the last include position so that "failure" wouldn't be defined before
the IO library was included.
2017-12-21 07:39:32 -05:00
John Ralls
0026b10851 Merge branch 'maint' into unstable 2017-12-17 13:00:00 -08:00
John Ralls
1c8c53a861 Remove (unused because of an error) parse-to-tm string timespec construction. 2017-12-12 21:02:11 -08:00
John Ralls
5204100d53 Use GNUInstallDirs in CMake Builds
Provides correct file layout when building distribution tarballs.
Fixes Bugs 790840 and 790841.
2017-11-28 14:25:35 -08:00
John Ralls
13657ee1bb Merge branch 'maint' into unstable 2017-11-25 15:35:24 -08:00
John Ralls
d8c2f52447 Correct quoting for SQL backends.
Only string values should be quoted in queries; in particular NULL
isn't a string value and must not be quoted.
Note that this is a less than perfect solution because it doesn't use
the Database's quoting function and so doesn't escape quotes, linefeeds,
or carriage returns inside the string. That's because the SQL generating
logic is independent of the connection class and can't easily get to it.
2017-11-25 14:46:31 -08:00
John Ralls
9c4635e393 Bug 784623 - GNUCash does not work with sql backend.
Wherin the problem is that MySQL's TIMESTAMP has a date range of
1970-01-01 00:00:01 to 2038-01-19 03:14:07 and is unable to handle
time_t of 0. MySQL's TIMESTAMP also assumes that input is in the server's
timezone and adjusts it to UTC. GnuCash has already done that conversion.
2017-11-23 11:41:09 -08:00
John Ralls
937f8c5083 Set GncSqlObjectBackend::m_version to the appropriate TABLE_VERSION.
For each subclass, getting rid of GNC_SQL_OBJECT_BACKEND_VERSION which
was a bit misguided.

Also remove the bogus test the skipped loading a table if its version
didn't match GNC_SQL_OBJECT_BACKEND_VERSION which was even more misguided.
2017-11-21 18:15:37 -08:00
John Ralls
04642fc42a [SQL] Check return of string_to_guid, bail if false. 2017-10-27 09:46:47 -07:00
John Ralls
d17c24b770 Bug 789298 - Prompt for file history update leads to crash during startup. 2017-10-27 09:46:47 -07:00
Geert Janssens
1238b9d8cd Prevent gcc from searching config.h in the current directory
This will avoid a ninja-build from picking up a config.h generated by the autotools build
(in the root build directory). Picking up the wrong config.h may lead to all kinds of
subtle issues if the autotools run was done with different options than the cmake run.
2017-10-26 14:05:17 +02:00
John Ralls
1e0a9a0ef8 Parse date strings into a struct tm and construct GDateTime with that.
Instead of using the more generic string constructor. The struct tm
constructor is several times faster and this change speeds up
transaction loading by 2x.
2017-08-20 21:28:09 +02:00
John Ralls
7e7d42847c Fix load string KVP memory error. 2017-08-19 17:15:49 +02:00
Geert Janssens
f943ba61ae Rename directory for code from external projects
'lib' is also being used by the cmake build, so there was a
theoretical risk for file conflicts. The new name is 'borrowed'.
2017-08-17 15:25:49 +02:00
John Ralls
e9ac71c0f9 Fix time-string format in backend for GncDateTime(std::string).
Also provide a simple test of that ctor.
2017-08-16 23:17:07 +02:00
John Ralls
43df1ccc3a Fix the most serious backend memory leaks. 2017-08-16 23:17:07 +02:00
Geert Janssens
83d14e1c1c Restructure the src directory
It is split into
- /libgnucash (for the non-gui bits)
- /gnucash (for the gui)
- /common (misc source files used by both)
- /bindings (currently only holds python bindings)

This is the first step in restructuring the code. It will need much
more fine tuning later on.
2017-08-10 18:45:00 +02:00