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 240988 - Matching Rows and Sorting not working as expected
Summary: Matching Rows and Sorting not working as expected
Status: VERIFIED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: Show Data (show other bugs)
Version: 8.0
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Libor Fischmeistr
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-26 23:34 UTC by MichaelHyde
Modified: 2014-02-14 07:01 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Screenshot_Sorting_by_111 (72.73 KB, image/jpeg)
2014-01-26 23:34 UTC, MichaelHyde
Details
Searching with a space (172.24 KB, image/jpeg)
2014-01-28 05:38 UTC, MichaelHyde
Details
Searching for Hello (177.43 KB, image/jpeg)
2014-01-28 05:39 UTC, MichaelHyde
Details
Searching Hello- (177.60 KB, image/jpeg)
2014-01-28 05:41 UTC, MichaelHyde
Details
Sample mySQL DB (35.13 KB, application/octet-stream)
2014-01-28 05:44 UTC, MichaelHyde
Details
Sort by post_title NOT WORKING (353.50 KB, image/jpeg)
2014-01-28 05:45 UTC, MichaelHyde
Details
potential patch v1 (19.00 KB, patch)
2014-01-28 21:41 UTC, matthias42
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description MichaelHyde 2014-01-26 23:34:11 UTC
Created attachment 144386 [details]
Screenshot_Sorting_by_111

I am connected to a mySQL database.

When looking at content of a table Matching Rows does not filter by data.

When typing a word into Matching Rows that is present in a row, all rows are removed from the list (filtered out).

Strange behavior occurs (i.e. filtering by "111" or "aaa" or "333" returns a row that does not have these "xxx" in the row.
Comment 1 matthias42 2014-01-27 00:57:07 UTC
Hey Michael,

could you please supply some more information (I tested with traveldb sample database and it works there, but I have some suspicions):

- If possible (that is this is a sample database, that you can share), please attach it as a gzipped dump.
- If this is not possible please state the table structure (show create table, describe table come to mind)
- If this is also not possible, please show the datatype of the column by hovering over the column head (the tooltip show JDBC type and DB-Type in 8.0, please include both).

Thank you!

Matthias
Comment 2 MichaelHyde 2014-01-27 16:15:27 UTC
Hello Matthias,

Thank you for the prompt reply.

I sent the requested db to you via email.

If that was not the preferred method, please respond and I will attach here.

Thanks!
Michael
Comment 3 MichaelHyde 2014-01-27 16:30:54 UTC
To be more specific

Sorting did not appear to work for:
select post_content from yun_posts;

Sorting did work for:
select user_email from yun_users;

I do not see JDBC and DB types when I hover over column head (just name, type, length).

Thanks!
Michael
Comment 4 matthias42 2014-01-27 19:19:54 UTC
Hi Michael, 

thank you for the info! Please also add the data here (as reference). Please note, that I'm not a netbeans developer. I provided patches to the netbeans db module and try to keep it clean ;-)

To make it easier for other readers: The problem occurs with LOB columns. The Sorter falls back to string based sorting and in this case the toString method is used. This in turn is not sooo well defined (aka the default implementation). Something like this is compared:

org.netbeans.modules.db.dataview.util.FileBackedClob@12462478
org.netbeans.modules.db.dataview.util.FileBackedClob@10e0c95f

This also explains the matches which I could not reproduce - matching and sorting is random (as is placement in ram).

Greetings Matthias
Comment 5 MichaelHyde 2014-01-28 05:38:17 UTC
Created attachment 144435 [details]
Searching with a space

Searching for "Hello " (with space) does not match "Hello World" in post_title
Comment 6 MichaelHyde 2014-01-28 05:39:52 UTC
Created attachment 144436 [details]
Searching for Hello

Searching for "Hello" (without space) does match "Hello World" in post_title and "hello-world" in post_name.
Comment 7 MichaelHyde 2014-01-28 05:41:20 UTC
Created attachment 144437 [details]
Searching Hello-

Searching for "Hello-" does match "hello-world" in post_name.
Comment 8 MichaelHyde 2014-01-28 05:44:14 UTC
Created attachment 144438 [details]
Sample mySQL DB

Sample DB Table used for this test.
Comment 9 MichaelHyde 2014-01-28 05:45:48 UTC
Created attachment 144439 [details]
Sort by post_title NOT WORKING

Sorting by post_title not working
Comment 10 matthias42 2014-01-28 21:41:26 UTC
Created attachment 144490 [details]
potential patch v1

Attached you find a preliminary patch - Libor could you please give it a closer look? I already gave an overview of the reason of this problem and the patch should fix that. Problem: I had not much time to test it, so while it works it needs a second pair of eyes.

The idea: Extract the string conversion routines for LOBs from the corresponding cellrenderers and celleditors into a common class (LobHelper.java). That in itself has the benefit of getting rid of the duplicate implementation. In Addition in LobHelper generic comparators for CLOBs and BLOBs are definied.

The BLOB comparator sorts by length, the CLOB comparator tries to extract the first 255 char (max) from the CLOB and sorts based on that case insensitive.

The comparators are then integrated by modifying the StringFallbackRowSorter.

The problem with "matching rows" can not be fixed totally - in this patch a partitial solution is reached by modifying SuperPatternFilter#testValue if a LOB reaches that method, the object is not converted to String via toString, but by using the introduced (cb)lobToString Methods in LobHelper. The result of the (cb)lobToString is then checked. For both types this filters based on what would have been display in the table - for the BLOB the content is ignored completely and for the CLOB only the first max 255 chars are checked. The limit of 255 chars was choosen, because it was already in the constraints for display and the whole text can't be resonably compared (its called _large_ object).

It's arguable whether that matching is correct for BLOB or if it should never match.

I hope this helps a bit.

PS: I noticed, that LobHelper could benefit from at least an explanation why it exists (sorry, no time to redo the patch)
Comment 11 Libor Fischmeistr 2014-02-10 11:52:02 UTC
Patch looks good to me. Applied in changeset: http://hg.netbeans.org/core-main/rev/4f78dec17ce1

Thanks for it.

Please verify the patch.

Thank you
Comment 12 Quality Engineering 2014-02-12 02:39:39 UTC
Integrated into 'main-silver', will be available in build *201402120001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/4f78dec17ce1
User: Libor Fischmeistr <lfischmeistr@netbeans.org>
Log: #240988: Matching Rows and Sorting not working as expected
Comment 13 matthias42 2014-02-13 20:18:02 UTC
Hey Libor,

thank you for checking and applying the patch. I checked the latest nightly and it works as I would expect (that is: matching text outside the first 255 chars does not work). That would not constitute a bug.

Greetings Matthias
Comment 14 Libor Fischmeistr 2014-02-14 07:01:34 UTC
(In reply to matthias42 from comment #13)
> Hey Libor,
> 
> thank you for checking and applying the patch. I checked the latest nightly
> and it works as I would expect (that is: matching text outside the first 255
> chars does not work). That would not constitute a bug.
> 
> Greetings Matthias

I thank you.