unable to search on raw string in sqlite database

Bug #678014 reported by Jelmer Vernooij
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Storm
New
Undecided
Unassigned

Bug Description

Searching on an object in a SQLite database by a raw string doesn't appear to work, as demonstrated by the attached script.

Tags: sqlite
Revision history for this message
Jelmer Vernooij (jelmer) wrote :
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

The attached patch fixes this particular issue, but it makes some other tests in the storm testsuite fail.

Jamu Kakar (jkakar)
Changed in storm:
milestone: none → 0.19
Revision history for this message
James Henstridge (jamesh) wrote :

If I edit the test program to insert the test program to insert the row as:

    db.execute("INSERT INTO foo (name) VALUES (?)", (buffer("bla"), ))

Then the assertion doesn't fire. If I poke around in the resulting database, I can't select the row by string comparison:

    sqlite> select * from foo;
    1|bla
    sqlite> select * from foo where name = 'bla';
    sqlite>

I guess sqlite is treating blobs and text strings as distinct here. If you insert the data as blobs, then you can't match it against an equivalent text string and vice versa.

Revision history for this message
Jelmer Vernooij (jelmer) wrote : Re: [Bug 678014] Re: unable to search on raw string in sqlite database

On Tue, 2011-01-04 at 08:06 +0000, James Henstridge wrote:
> If I edit the test program to insert the test program to insert the row
> as:
>
> db.execute("INSERT INTO foo (name) VALUES (?)", (buffer("bla"), ))
>
> Then the assertion doesn't fire. If I poke around in the resulting
> database, I can't select the row by string comparison:
>
> sqlite> select * from foo;
> 1|bla
> sqlite> select * from foo where name = 'bla';
> sqlite>
>
> I guess sqlite is treating blobs and text strings as distinct here. If
> you insert the data as blobs, then you can't match it against an
> equivalent text string and vice versa.

Yeah, that's what I found later as well. I'm currently using Cast() to
work around this issue, basically:

SELECT * from foo WHERE CAST(name AS BLOB) = CAST('bla' AS BLOB);

The dynamic typing in SQLite is a bit annoying here, and as far as I
know there is no way to disable it. :-/

Cheers,

Jelmer

Revision history for this message
James Henstridge (jamesh) wrote :

Is there any reason to leave this bug open then?

Barry Warsaw (barry)
Changed in storm:
milestone: 0.19 → 0.20
Changed in storm:
milestone: 0.20 → 0.21
Colin Watson (cjwatson)
Changed in storm:
milestone: 0.21 → 0.22
Colin Watson (cjwatson)
Changed in storm:
milestone: 0.22 → none
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.