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
Created attachment 373223 [details] Sample patch to resolve the issue