GnuCash
Contact   Instructions
Bug 797147 - invoice.GetDatePosted() returns 1970-01-01 for unposted invoices in MySQL backend rather than Null
Summary: invoice.GetDatePosted() returns 1970-01-01 for unposted invoices in MySQL bac...
Status: NEW
Alias: None
Product: GnuCash
Classification: Unclassified
Component: Python Bindings (show other bugs)
Version: git-maint
Hardware: PC Linux
: Normal normal
Target Milestone: ---
Assignee: core
QA Contact: core
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-20 16:28 EDT by Tom Lofts
Modified: 2019-03-20 16:31 EDT (History)
1 user (show)

See Also:


Attachments
Example Python script reproducing issue (1.03 KB, text/x-python)
2019-03-20 16:28 EDT, Tom Lofts
no flags Details
Sample patch to resolve the issue (620 bytes, patch)
2019-03-20 16:30 EDT, Tom Lofts
no flags Details

Description Tom Lofts 2019-03-20 16:28:10 EDT
Created attachment 373222 [details]
Example Python script reproducing issue

When creating an invoice e.g. with invoice = Invoice(book, "1", GBP, customer), invoice.GetDatePosted() returns Null prior to the invoice being posted.

However when using the MySQL backend, after the session is closed and the reopened, invoice.GetDatePosted() on the same invoice now returns 1970-01-01.

After reviewing the SQL backend, I feel this is because theres no check for nulls on these columns, so the a 0 is returned which is then converted from a unix timestamp to 1970-01-01.

Looking at some of the other null handling code, I feel a row.is_col_null() is required in GncSqlColumnTableEntryImpl<CT_TIME> in gnc-sql-column-table-entry.cpp to check for nulls and return before continuing further though I'd appreciate someone with a bit more knowledge of the SQL/DBI backend investigating this further and appreciate this issue might have implications outside of the Python bindings.

I've attached a python script reproducing the issue.

Kind regards,

Tom
Comment 1 Tom Lofts 2019-03-20 16:30:50 EDT
Created attachment 373223 [details]
Sample patch to resolve the issue

Note You need to log in before you can comment on or make changes to this bug.