This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 157526 - MySQL database names, table names and column names should be backticked
Summary: MySQL database names, table names and column names should be backticked
Status: RESOLVED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Jiri Rechtacek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-28 06:29 UTC by robertgonzalez
Modified: 2013-07-17 22:16 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description robertgonzalez 2009-01-28 06:29:34 UTC
When running a SQL query the database name(s), table name(s) and column name(s) are not backticked. Since backticking
database, table and column names escapes reserved words and is a sure fire way to making sure that queries will run no
matter the database, table or column name it would make sense to have the IDE automatically backtick database, table and
column names in both the SQL Explorer and code generators in the IDE.

To replicate an issue I am having with this, create a database and a table named databases. Then run a simple "SELECT *
FROM databases" query and you will get an error. If the query were "SELECT * FROM `databases`" then the query would run
without issue.
Comment 1 Tomas Mysik 2009-01-28 08:30:30 UTC
Incorrect component, reassigning, please evaluate. Thanks.

To reporter: please note that "backticking" is not SQL standard, it is MySQL specific behaviour.
Comment 2 robertgonzalez 2009-01-28 17:46:29 UTC
I understand that backticks are MySQL specific, but the database is a MySQL database using a MySQL JDBC driver. 
Wouldn't the IDE be able to know that it is connected to a MySQL database and add the backticks accordingly? To take 
that a step further, should the IDE be able to properly escape reserved words for all database layers it might talk to?
Comment 3 Jiri Rechtacek 2009-10-16 14:09:18 UTC
Reassigned to new owner.
Comment 4 matthias42 2013-07-17 22:16:54 UTC
The SQL identifier quote string is the double-quotation mark: "

I was writing that using it is a bad idea, if it is not needed and there might be big behavioral changes in identifier handling in the DBMS. Then I remembered, that I stumbled over code that realised that. 

Checked in netbeans 7.3 against a derby database:

1. Execute: create table "table" (id int, name varchar(255));
2. Right click on the newly created node "table" under the "Tables" node
3. select "View data"

You get this sql:

select * from APP."table";

This is the intended syntax. I'll asume this is similar handled for mysql (my server is down, so can't check right now).