Andy Ross wrote:
Andy Ross wrote:
Problem is, the *blob* value of "testval" does not, apparently, equal
the *text* value of "testval" in the database.
Just to head off the inevitable reply: no, this isn't an encoding issue.
The result of "pragma encoding" on the database file is UTF-8, and
obviously
the transformation between UTF-8 and an ASCII string is the identity
transform.
Andy,
You have discovered a "quirk" in SQLite. I'm not sure if it should be
called a bug, or not.
The following log shows that sqlite does indeed distinguish between a
text field and a blob with the same content. It also shows you a
workaround. You simply need to cast your fields to blobs before you
compare them to a variable that is bound to a blob.
sqlite> create table t (a text);
sqlite> insert into t values (X'74657374');
sqlite> insert into t values ('test');
sqlite> select * from t;
test
test
sqlite> select count(*) from t where a = X'74657374';
1
sqlite> select count(*) from t where a = X'7465737400';
0
sqlite> select count(*) from t where a = 'test';
1
sqlite> select typeof(a) from t;
blob
text
sqlite> select count(*) from t where cast(a as blob) = 'test';
0
sqlite> select count(*) from t where cast(a as blob) = X'74657374';
2
HTH
Dennis Cote
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------