gnucash maint: Bug 798448 - Column 'num' cannot be null

John Ralls jralls at code.gnucash.org
Thu Mar 3 19:08:44 EST 2022


Updated	 via  https://github.com/Gnucash/gnucash/commit/4890c253 (commit)
	from  https://github.com/Gnucash/gnucash/commit/8ef8d380 (commit)



commit 4890c25376145a2fe09e517a6f9a4bcc705830eb
Author: John Ralls <jralls at ceridwen.us>
Date:   Thu Mar 3 15:36:08 2022 -0800

    Bug 798448 - Column 'num' cannot be null
    
    Convert libofx's data.check_number and data.reference_number to "" if
    they are any case variation of "null".
    
    Note that SQL backends will not permit the word NULL as a value for the
    number field if it's entered from the GUI, but this can be worked around
    by quoting it as in Scheme: 'Null *will* work.

diff --git a/gnucash/import-export/ofx/gnc-ofx-import.c b/gnucash/import-export/ofx/gnc-ofx-import.c
index b77284a6c..d6527561c 100644
--- a/gnucash/import-export/ofx/gnc-ofx-import.c
+++ b/gnucash/import-export/ofx/gnc-ofx-import.c
@@ -614,7 +614,14 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data, void *user_data)
             /* set tran-num and/or split-action per book option */
             if (data.check_number_valid)
             {
-                gnc_set_num_action(transaction, split, data.check_number, NULL);
+                /* SQL will correctly interpret the string "null", but
+                 * the transaction num field is declared to be
+                 * non-null so substitute the empty string.
+                 */
+                const char *num_value =
+                    strcasecmp (data.check_number, "null") == 0 ? "" :
+                    data.check_number;
+                gnc_set_num_action(transaction, split, num_value, NULL);
             }
             else if (data.reference_number_valid)
             {



Summary of changes:
 gnucash/import-export/ofx/gnc-ofx-import.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)



More information about the gnucash-changes mailing list