Help with libdbi code

Colin Law clanlaw at gmail.com
Tue May 10 10:14:58 EDT 2016


Given the question over the advisability of changing the db schema on
a minor release, with the associated issues of migrating the database
and so on I have reverted to plan A and written code to modify the
session sql_options each time we connect to the server.  A pull
request will be generated shortly.  As this is the first non-trivial
code I have contributed no doubt I will have contravened a number of
conventions, which I will happily sort out as they are raised.

On the issue of testing, is it necessary to extend the tests to cover
this?  The only area I can see that could be easily tested is the code
that removes the NO_ZERO_DATE option from the options string.  I have
tested that thoroughly with a simple test harness, testing strings
with the option missing, with it at the start, end and middle of the
string and with an that option as a substring of another option (not
likely to happen I know).  One should probably bear in mind that this
code will likely not be required on the next major release, assuming
that the database schema is updated instead.

Off topic;
I have not used C for several years and had forgotten what hard work
it is working with strings. When I first met C at the end of the 70's
it was a revelation and I used it and later C++ for many years, but
now it does seem tedious.  I still have my orginal Kernighan and
Ritchie which I remember reading from cover to cover whilst waiting
with great anticipation for my C compiler to arrive.  Recently I have
been using Ruby and the method in the pull request to remove the
option from the option string could be written in Ruby as something
like

new_options = (options.split(',') - ["NO_ZERO_DATE"]).join(',')

It would no doubt take very much longer to execute, but nowadays that
is often of little consequence.  Of course C/C++ does have numerous
advantages over languages such as Ruby, particularly when it comes to
large systems such as GnuCash.

Regards

Colin

On 7 May 2016 at 22:14, Colin Law <clanlaw at gmail.com> wrote:
> On 7 May 2016 at 21:44, Colin Law <clanlaw at gmail.com> wrote:
>> ...
>> I am running with
>> type_name = "TIMESTAMP NULL";
>> and have not found any problems so far.
>>
>
> On further investigation I am getting errors.  When I attempt to save
> as mysql I get
> CRIT <gnc.backend.dbi> [mysql_error_fn()] DBI error: 1067: Invalid
> default value for 'date_closed'
> This is related to gnc-order-sql.c line 64.  I suspect the orders
> table does not use BCT_DATETIME for its column definitions.
>
> Will investigate further tomorrow.
>
> Colin


More information about the gnucash-devel mailing list