After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 700197 - Critical SQL backend errors when creating customers via python bindings
Critical SQL backend errors when creating customers via python bindings
Status: RESOLVED FIXED
Product: GnuCash
Classification: Other
Component: Python Bindings
git-master
Other Linux
: Normal normal
: ---
Assigned To: Mark Jenkins
Mark Jenkins
Depends on:
Blocks:
 
 
Reported: 2013-05-12 18:31 UTC by Tom Lofts
Modified: 2018-06-29 23:15 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to resolve critial sql backend errors (1.26 KB, patch)
2013-05-12 18:35 UTC, Tom Lofts
none Details | Review

Description Tom Lofts 2013-05-12 18:31:06 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
Comment 1 Tom Lofts 2013-05-12 18:35:01 UTC
Created attachment 243946 [details] [review]
Patch to resolve critial sql backend errors
Comment 2 Mike Evans 2013-05-13 08:39:05 UTC
Thank you for reporting this bug and the patch.

Applied to trunk. 
SVN r22977
Comment 3 John Ralls 2018-06-29 23:15:58 UTC
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.