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 179413 - Netbeans wrongly quotes identifiers in update statements issued from datagrid
Summary: Netbeans wrongly quotes identifiers in update statements issued from datagrid
Status: RESOLVED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: SQL Editor (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P3 normal (vote)
Assignee: Jiri Rechtacek
URL:
Keywords: NETFIX
Depends on:
Blocks:
 
Reported: 2010-01-12 05:11 UTC by matthias42
Modified: 2011-10-20 14:26 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Patch for variant 2 (1.73 KB, patch)
2011-03-12 21:21 UTC, matthias42
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description matthias42 2010-01-12 05:11:37 UTC
Hello,

I set a query from the SQL-Editor and used the build in editing feature. When I tried to commit the change, I got an syntax error from the database server. Further investigation using wireshard showed, that the send sql contained identierts quoted by ".

In this case this was issued against an Informix 11.5 server, which rightly refused this sql:

UPDATE "stellenangebot" SET "verguetung" = ? WHERE "id" = ?

Using the correct syntax:

UPDATE stellenangebot SET verguetung = ? WHERE id = ?

works as expected.

Checking the database meta data: getIdentifierQuoteString() showed, that there is no quoting string.

So - the best way seems to be using the supplied Quoting String or at least don't try to make clever guesses about the db.

My current question: Can there be a hotfix?

Additional Info: This was done with the jdbc informix driver version 3.50.JC3DE.
Comment 1 matthias42 2010-01-12 05:29:14 UTC
Ah - I just found the work around: You have to provide DELIMIDENT=y in the JDBC URL, so that the SQL Server interprets the SQL sent by netbeans correctly.
Comment 2 matthias42 2011-01-26 20:11:22 UTC
Ok, I had another look at the sourcecode and identified a several possible points for correction:

1. Maybe IBM is at fault: The API defines, that a space should be returned, if quoting is disabled, Informix returns an string with length 0 => Ok, but will IBM fix this in reasonable time?

2. Maybe the error lies in SQLIdentifiers.java which messes with the quote String returned by the database => is there a reason els removing lines 320-322 in SQLIdentifiers.java would solve this problem (there " is returned as Quote-String if the quoteString length if zero (see point 1 and introduction).

3. Maybe SQLStatementGenerator.java and SQLExecutionHelper are at fault: They request the identifiers are quoted, whether its necessary or not. getFullyQualifiedName already checks whether quoting is necessary, but its superseeded by the quoteAlways parameter.

So I suggest:

1. Change all uses of getFullyQualifiedName(true) to getFullyQualifiedName(false)
   => only quote if necessary (in my use-case the data editor this should solve all problems.

2. Fix getQuoteString by checking for informix and in this case enable the empty quote char => Will possibly produce faults, but then the database would never have accepted the identifier name

3. May IBM do the right thing by returing " " instead of ""

I ordered the suggestions by my view of the effort needed and the impact. For most cases 1 alone should suffice.

Additionally the Dialog when creating a new DB Connection in netbeans should indicate, that it would be wise to specify DELIMIDENT=y in the jdbc URL and that then the SQL Syntax has to be adjusted.
Comment 3 matthias42 2011-03-12 21:21:53 UTC
Created attachment 106942 [details]
Patch for variant 2

Variant 2: Check whether the driver can be trusted when an empty string is returned as quiting character.
Comment 4 matthias42 2011-05-18 19:28:17 UTC
Are there any updates on this? The patch is not that intrusive and the bug get annoying very quick.
Comment 5 Jiri Rechtacek 2011-05-27 09:55:10 UTC
the patch was applied in core-main/rev/7e38f2e23d79, I just change method access from protected to private to avoid API change process unless there is use-case this method by another module. Fixed in daily builds now, I'm going to backport it also to upcoming NB7.0.1 release.
Thank you for fixing it.
Comment 6 Jiri Rechtacek 2011-05-27 10:44:04 UTC
releases/rev/7ece72a3e2f5
Comment 7 Quality Engineering 2011-05-28 12:18:47 UTC
Integrated into 'main-golden', will be available in build *201105280401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/7e38f2e23d79
User: Jiri Rechtacek <jrechtacek@netbeans.org>
Log: #179413: Netbeans wrongly quotes identifiers in update statements issued from datagrid;
applied matthias42's patch
Comment 8 Quality Engineering 2011-10-20 14:26:32 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/3a3f7510183c
User: Jiri Rechtacek <jrechtacek@netbeans.org>
Log: #200783 - Endless loop in command completion when quoteString = "" (Bugs: #179413, #167564);
applied matthias42's patch, thanks