GNOME Bugzilla – Bug 771254
Cannot save to MySQL database containing hyphens
Last modified: 2018-06-29 23:51:01 UTC
When trying to connect to a database containing an hyphen, GnuCash returns a data corruption error. Investigating the content of the packets exchanged between GnuCash and the database, I discovered that GnuCash doesn't correctly escape the database name. For example, using "something-gnucash" as the name for the database (a perfectly valid name for MySQL and possibly other DBMSs) results in the following query being sent: USE something-gnucash which results in an error, as MySQL, when encountering an hyphen in this context, decides that it's parting a variable name. The problem can be easily solved by enclosing the database name in backticks: USE `something-gnucash` which is the "most correct" method for addressing databases and tables in SQL anyway, especially for dynamically generated queries. Please note that I'm using the "USE database" query as an example, the problem exists for all other queries with database names in them.
Also note that this probably applies to platforms other than Windows. If anyone can confirm, please edit the report to reflect this.
Thanks for taking the time to report this. This particular bug has already been reported into our bug tracking system, but we are happy to tell you that the problem has already been fixed in the code repository, though unfortunately not for the current stable release series. *** This bug has been marked as a duplicate of bug 769115 ***
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=771254. Please update any external references or bookmarks.