GNOME Bugzilla – Bug 700197
Critical SQL backend errors when creating customers via python bindings
Last modified: 2018-06-29 23:15:58 UTC
As per a post of mine to the guncash-user mailing list (http://lists.gnucash.org/pipermail/gnucash-user/2013-March/048440.html) there appears to be a bug when creating customers inserting into existing databases via the python bindings. Currently the following python script to create a customer: from gnucash import Session from gnucash.gnucash_business import Customer session = Session('mysql://user:password@localhost/gnucash_test') book = session.book commod_table = book.get_table() currency = commod_table.lookup('CURRENCY', 'GBP') new_customer = Customer(book, "22222", currency, "Test") session.save() session.end() session.destroy() Results in the following error: * 14:44:14 CRIT <gnc.backend.dbi> [mysql_error_fn()] DBI error: 1048: Column 'currency' cannot be null * 14:44:14 CRIT <gnc.backend.dbi> [conn_execute_nonselect_statement()] Error executing SQL INSERT INTO customers(guid,name,id,notes,active,discount_num,discount_denom,credit_num,credit_denom,currency,tax_override,addr_name,addr_addr1,addr_addr2,addr_addr3,addr_addr4,addr_phone,addr_fax,addr_email,shipaddr_name,shipaddr_addr1,shipaddr_addr2,shipaddr_addr3,shipaddr_addr4,shipaddr_phone,shipaddr_fax,shipaddr_email,terms,tax_included,taxtable) VALUES('b460bab5be705d67a7a89b1c8ae83509','','22222','',1,0,1,0,1,NULL,0,'','','','','','','','','','','','','','','','',NULL,3,NULL) * 14:44:14 CRIT <gnc.backend.sql> [gnc_sql_do_db_operation()] SQL error: INSERT INTO customers(guid,name,id,notes,active,discount_num,discount_denom,credit_num,credit_denom,currency,tax_override,addr_name,addr_addr1,addr_addr2,addr_addr3,addr_addr4,addr_phone,addr_fax,addr_email,shipaddr_name,shipaddr_addr1,shipaddr_addr2,shipaddr_addr3,shipaddr_addr4,shipaddr_phone,shipaddr_fax,shipaddr_email,terms,tax_included,taxtable) VALUES('b460bab5be705d67a7a89b1c8ae83509','','22222','',1,0,1,0,1,NULL,0,'','','','','','','','','','','','','','','','',NULL,3,NULL) * 14:44:14 CRIT <gnc.business> [gncCustomerOnError()] Customer QofBackend Failure: 12 Table Retrieval Error: 1048: Column 'currency' cannot be null * 14:44:18 CRIT <gnc.backend.dbi> gnc_dbi_unlock: assertion `dbi_conn_error( dcon, NULL ) == 0' failed After some investigation, the python code appears to differ from the core code with gncCustomerBeginEdit and gncCustomerCommitEdit, but not in the GnuCashBusinessEntity class in gnucash_business.py I have created a very small patch to resolve this issue and submit it as part of this bug report. Kind regards, Tom
Created attachment 243946 [details] [review] Patch to resolve critial sql backend errors
Thank you for reporting this bug and the patch. Applied to trunk. SVN r22977
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=700197. Please update any external references or bookmarks.