The default implementation of org.netbeans.api.db.sql.support.SQLIdentifiers.Quoter does not correctly quote/unquote identifiers that contains the quote string itself. The correct way to do quote the quote string is, as far as I know, to include it twice (at least for MySQL and Postgres--I just tried it).
For instance, in MySQL, the quote string is "`" (a single backtick character), and so a table named "Table with `Backticks` and Spaces" should be quoted as "`Table with ``Backticks`` and Spaces`".
The bug can be exhibited for instance by creating a table in MySQL with a name containing a backtick character, then connecting to the database from NetBeans, and then clicking "View Data..." on the table to see the generated query with the incorrect quoting.
The methods that need updating are Quoter.doQuote(), Quoter.unquote(), and probably DatabaseMetaDataQuoter.needToQuote() (the latter to ensure that the identifier does not contain the quote string).
(As an aside: I wonder if there are databases out there that quote the quote character differently...)
Created attachment 130405 [details]
proposed patch v1 part 1
The diagnosis is correct and reproducible. The first attached patch fixes this and adds a unit-test for this.
Created attachment 130406 [details]
proposed patch v1 part 2
Part 2 of the patch - the lexer did not correctly worked with identifier quoting characters other than ". The patch includes a modified unit-test.
Thanks--I'm impressed by the swift response :-)
(I take back my earlier suggestion that DatabaseMetaDataQuoter.needToQuote() needed to be changed--the patch looks good.)
Integrated as http://hg.netbeans.org/core-main/rev/2faf2562a671
Thank you very much for reporting, Ebakke, and for the patch, Matthias!
Integrated into 'main-golden', will be available in build *201302092300* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
User: Jaroslav Havlin <firstname.lastname@example.org>
Log: #225079: SQLIdentifiers.Quoter does not correctly quote identifiers containing the quote character itself