[67cat][other] DB Explorer bug + fix

View: New views
3 Messages — Rating Filter:   Alert me  

[67cat][other] DB Explorer bug + fix

by choc_dan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have discovered a bug in the database explorer and I believe that I now have a fix for it.

Opening up a SQLServer database connection in the database explorer presents the users with a list of all catalogs on that server under which may be any number of schemas.  The catalog and schema that was specified with the connection acts as a default and it shown in bold.  Right-clicking a table in the database explorer lets the user view the contents of the table (via "View data...".  This fails for non-default catalogs because netbeans never qualifies the table name with the catalog.  The catalog can be pre-pended to the table name in the SQL editor to retrieve the table contents.

At this point I should note that netbeans always prepends the table name with the schema even when it is not needed.  Moreover the code contains a hack so that if the database variant (such as MySQL) does not have a schema then the catalog is always prepended, thereby ensuring that table data can always be retrieved against MySQL.  That the schema is always pre-pended is however due to some incorrect code as the logic in the NB code suggests that it should only be conditionally pre-pended!


I have fixed the above problems in my check-out of the development version of NB (last updated yesterday).  The fix is in a single small Java class and so should be fairly straightforward to review.  I need a final test against SQLServer before I am completely satisfied with it, which I can do when I get into work on Monday.  But what next?  My understanding is that there is no longer a team developing the database functionality.  So is there anyone who would verify and apply the fix?

Daniel Sheppard



PS: By way of illustration using the sakila sample database (aka catalog), NB gives

select * from sakila.city

when all that is needed is

select * from city

Re: [67cat][other] DB Explorer bug + fix

by Michel Graciano :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Daniel,
there is issue filed for this behaviour? Please, if not, file an issue against it, attach the patch and we can track it by NetFIX [1] program and your patch could be integrated as soon as it is reviewed.

Regards
[1] http://wiki.netbeans.org/NetFIX

On Thu, Jun 25, 2009 at 6:05 PM, Daniel Sheppard <choc_dan@...> wrote:
I have discovered a bug in the database explorer and I believe that I now have a fix for it.

Opening up a SQLServer database connection in the database explorer presents the users with a list of all catalogs on that server under which may be any number of schemas.  The catalog and schema that was specified with the connection acts as a default and it shown in bold.  Right-clicking a table in the database explorer lets the user view the contents of the table (via "View data...".  This fails for non-default catalogs because netbeans never qualifies the table name with the catalog.  The catalog can be pre-pended to the table name in the SQL editor to retrieve the table contents.

At this point I should note that netbeans always prepends the table name with the schema even when it is not needed.  Moreover the code contains a hack so that if the database variant (such as MySQL) does not have a schema then the catalog is always prepended, thereby ensuring that table data can always be retrieved against MySQL.  That the schema is always pre-pended is however due to some incorrect code as the logic in the NB code suggests that it should only be conditionally pre-pended!


I have fixed the above problems in my check-out of the development version of NB (last updated yesterday).  The fix is in a single small Java class and so should be fairly straightforward to review.  I need a final test against SQLServer before I am completely satisfied with it, which I can do when I get into work on Monday.  But what next?  My understanding is that there is no longer a team developing the database functionality.  So is there anyone who would verify and apply the fix?

Daniel Sheppard



PS: By way of illustration using the sakila sample database (aka catalog), NB gives

select * from sakila.city

when all that is needed is

select * from city



--
Michel Graciano
Summa Technologies do Brasil Ltda.
http://www.michelgraciano.com
https://genesis.dev.java.net/
http://translatedfiles.netbeans.org/index_pt_BR.html
https://copypastehistory.dev.java.net/

Re: [67cat][other] DB Explorer bug + fix

by choc_dan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Michel,

It seems that someone has recently filed this as http://www.netbeans.org/issues/show_bug.cgi?id=166549.  Apparently it is also a bug in Eclipse, so it would be nice to get one over :)

I have added some explanation to this issue and attached my diff.  I have verified it against MySQL and SQLServer.

Thanks

Dan

On Friday 26 Jun 2009 13:44:49 Michel Graciano wrote:

> Hi Daniel,
> there is issue filed for this behaviour? Please, if not, file an issue
> against it, attach the patch and we can track it by NetFIX [1] program and
> your patch could be integrated as soon as it is reviewed.
>
> Regards
> [1] http://wiki.netbeans.org/NetFIX
>
> On Thu, Jun 25, 2009 at 6:05 PM, Daniel Sheppard <choc_dan@...>wrote:
>
> > I have discovered a bug in the database explorer and I believe that I now
> > have a fix for it.
> >
> > Opening up a SQLServer database connection in the database explorer
> > presents the users with a list of all catalogs on that server under which
> > may be any number of schemas.  The catalog and schema that was specified
> > with the connection acts as a default and it shown in bold.  Right-clicking
> > a table in the database explorer lets the user view the contents of the
> > table (via "View data...".  This fails for non-default catalogs because
> > netbeans never qualifies the table name with the catalog.  The catalog can
> > be pre-pended to the table name in the SQL editor to retrieve the table
> > contents.
> >
> > At this point I should note that netbeans always prepends the table name
> > with the schema even when it is not needed.  Moreover the code contains a
> > hack so that if the database variant (such as MySQL) does not have a schema
> > then the catalog is always prepended, thereby ensuring that table data can
> > always be retrieved against MySQL.  That the schema is always pre-pended is
> > however due to some incorrect code as the logic in the NB code suggests that
> > it should only be conditionally pre-pended!
> >
> >
> > I have fixed the above problems in my check-out of the development version
> > of NB (last updated yesterday).  The fix is in a single small Java class and
> > so should be fairly straightforward to review.  I need a final test against
> > SQLServer before I am completely satisfied with it, which I can do when I
> > get into work on Monday.  But what next?  My understanding is that there is
> > no longer a team developing the database functionality.  So is there anyone
> > who would verify and apply the fix?
> >
> > Daniel Sheppard
> >
> >
> >
> > PS: By way of illustration using the sakila sample database (aka catalog),
> > NB gives
> >
> > select * from sakila.city
> >
> > when all that is needed is
> >
> > select * from city
> >
>
>
>