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 771254 - Cannot save to MySQL database containing hyphens
Cannot save to MySQL database containing hyphens
Status: RESOLVED DUPLICATE of bug 769115
Product: GnuCash
Classification: Other
Component: Backend - SQL
2.6.13
Other Windows
: Normal minor
: ---
Assigned To: gnucash-core-maint
gnucash-core-maint
Depends on:
Blocks:
 
 
Reported: 2016-09-11 17:22 UTC by Riccardo Paolo Bestetti
Modified: 2018-06-29 23:51 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Riccardo Paolo Bestetti 2016-09-11 17:22:23 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.
Comment 1 Riccardo Paolo Bestetti 2016-09-11 17:24:06 UTC
Also note that this probably applies to platforms other than Windows. If anyone can confirm, please edit the report to reflect this.
Comment 2 John Ralls 2016-09-11 18:45:23 UTC
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 ***
Comment 3 John Ralls 2018-06-29 23:51:01 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=771254. Please update any external references or bookmarks.