sqlitebrowser / sqlitebrowser

Official home of the DB Browser for SQLite (DB4S) project. Previously known as "SQLite Database Browser" and "Database Browser for SQLite". Website at:
https://sqlitebrowser.org
Other
20.98k stars 2.13k forks source link

putting a numeric value in an integer column filter in Browse mode is doing something strange #2191

Closed JonPGrewer closed 4 years ago

JonPGrewer commented 4 years ago

Details for the issue

I have a table with several integer fields. When I put a value in the filter field it returns all records that have that digit or digits in them. in other words: t1.id = integer I have records like the following: 24 42 84 92

In Browse Data, If I put a value of 2 in the filter it returns 24, 42, 92. If I put a value of 4 in the filter it returns 24, 42, 84.

But I have confirmed that the data type is integer when I read the records out. It is treating these fields as though they are text and doing a "like" clause with the filter value. Is this as designed?

Kind regards, Jon G.

What did you do?

BEGIN TRANSACTION; CREATE TABLE IF NOT EXISTS "tblPops" ( "id" INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, "itemno" TEXT, "series" TEXT, "description" TEXT, "date" TEXT, "price" REAL ); INSERT INTO "tblPops" ("id","itemno","series","description","date","price") VALUES (1,'199','Marvel Guardians of the Galaxy Vol 2','Gamora','2020-04-15 00:00:00',33.0), (2,'265','Marvel Spiderman Homecoming','Spiderman (Headphones)','2020-04-15 00:00:00',21.0), (3,'177','Overwatch','D.Va with Meka','2020-04-15 00:00:00',19.0); COMMIT;

What did you expect to see?

type "1" in price column filter in Browse mode. Price is type REAL. Expected to see no records since there are no exact matches of this numeric field. The same thing happens with integer columns.

What did you see instead?

Instead I saw two matches: 21.0 and 19.0 BugReport20200407

Useful extra information

DB4S v3.11.2 [built for x86_64-little_endian-llp64] on Windows 10 (10.0) (winnt/10.0.18363) [x86_64] using SQLite Version 3.27.2 and Qt 5.11.3

justinclift commented 4 years ago

Hmmm, I think this is working as designed, and what you're looking for is to use the equal sign = before the number. eg =1, =2, etc.

If it helps, our filtering page on the wiki kind of covers this:

    https://github.com/sqlitebrowser/sqlitebrowser/wiki/Using-the-Filters

It doesn't mention type information exactly, but as mentioned above I think the equals sign piece is the initial bit to read. :smile:

JonPGrewer commented 4 years ago

Thank you so much for that pointer. As you said, the page does indicate that. What confused me is that the sqlite documentation specifically says that you can't use "like" on a numeric value, only on text. However, I found elsewhere that it is possible to "cast" numeric fields as text, as in sql, for the purpose of doing a "like" search on integers and floats. Thanks so much again.

-Jon G

JonPGrewer commented 4 years ago

Thanks for the help again! I am closing this issue.

justinclift commented 4 years ago

You're welcome @JonPGrewer. :smile: