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 129330 - Code displaying column names should use getColumnLabel() instead of getColumnName()
Summary: Code displaying column names should use getColumnLabel() instead of getColumn...
Status: VERIFIED FIXED
Alias: None
Product: obsolete
Classification: Unclassified
Component: visualweb (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker with 1 vote (vote)
Assignee: John Baker
URL:
Keywords:
: 132647 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-03-05 17:37 UTC by David Vancouvering
Modified: 2008-06-04 08:37 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Vancouvering 2008-03-05 17:37:53 UTC
See issue 129271 - the new MySQL 5.1.5 driver we include is now compliant in that it returns the actual column name, not
the column *label*, when you call ResultSetMetaData.getColumnName().

The problem is that when the query includes an alias, e.g. "SELECT lastname as last from person" with 5.1.5 you will get
"lastname" instead of "last" when you call getColumnName().

To fix this the URL should use "useOldAliasMetadataBehavior=true".

Then, in our code, we need to change things as such: if you want the *actual* column name use getColumnName(), but in
use cases where you want to show the label/alias, and not the actual name, use getColumnLabel().
Comment 1 John Baker 2008-03-25 19:46:28 UTC
davidvc are you suggesting to replace getColumnName() with getColumnLabel() or just for MySQL?
Comment 2 David Vancouvering 2008-03-25 20:28:07 UTC
Yes, use getColumnLabel() instead of getColumnName() unless you want the actual name (e.g. for managing metadata).  I
suspect in most if not all cases we're getting the name so we can display it to the user, in which case what we want is
the label, not the name.  This is for all databases, not just MySQL.
Comment 3 John Baker 2008-03-26 01:03:34 UTC
I'll make a local change and try this out.  If no issues then I'll integrate into 6.1
Comment 4 John Baker 2008-03-27 22:10:07 UTC
This might be a risky fix for 6.1 - might break existing applications ?  Since 129271 is marked for future, is it ok for
this to be fixed for the next release?
Comment 5 David Vancouvering 2008-03-27 22:44:21 UTC
It's your call - I don't know the impact as well as you.  Not essential to fix, it is a P3 after all.  The workaround is
to add the "useOldAliasMetadataBehavior=true" property to the URL when using the new driver.
Comment 6 John Baker 2008-03-27 23:20:13 UTC
since there's a workaround and to play it safe, I'll set the target milestone to future
Comment 7 John Baker 2008-04-21 20:12:33 UTC
Replacing getColunnName() with getColumnLabel() , DnD database table and CRUD applications work for MySQL and other
databases: Oracle, DB2, Firebird, Postgres, MSSSQL, Derby

Comment 8 John Baker 2008-04-21 20:17:34 UTC
http://hg.netbeans.org/main/rev/ad2b12041257
Comment 9 John Baker 2008-04-21 20:18:58 UTC
*** Issue 132647 has been marked as a duplicate of this issue. ***
Comment 10 John Baker 2008-04-22 02:39:47 UTC
I made some mistakes and corrected some or all of them.  
http://hg.netbeans.org/main/rev/c35f0e22ee80

Comment 11 Roman Mostyka 2008-04-22 15:07:47 UTC
Verified with trunk build 080422. Do push into patch1 branch.
Comment 12 John Baker 2008-04-23 00:06:17 UTC
2 more change sets
88e3245243c7
a29eee5900b0

also these changesets would need to be transplanted to the patch

c35f0e22ee80
ad2b12041257
Comment 13 John Baker 2008-04-23 00:07:15 UTC
*** Issue 133672 has been marked as a duplicate of this issue. ***
Comment 14 John Baker 2008-04-23 19:20:51 UTC
Added setColumnLabel

So in addition to the changesets in the previous comment also need to include
8bf6efc2b437
b449dff4241c
Comment 15 Quality Engineering 2008-04-24 03:52:22 UTC
Issue '129330' Integrated in NB_Trunk_Production #154 : http://hg.netbeans.org/main/rev/8bf6efc2b437,
 with comment: #129330 Code displaying column names should use getColumnLabel() instead of getColumnName(); need to add setColumnLabel
Comment 16 jinb 2008-05-03 14:35:07 UTC
backported into release61_fixes branch
changeset:   77531:001be38e24d4