[sqlite] Why is empty string not equal to empty blob?

2015-03-30 Thread dmp
> You explicitly put strings into both columns. The two values are the same > even though you declared the columns differently. As I told you before, > if you want to see what type something is, use typeof(thing). > > ~ > ~ > ~ > ~ > > Simon. Thank you guys. I follow this list so I

[sqlite] Why is empty string not equal to empty blob?

2015-03-29 Thread Luuk
On 29-3-2015 18:53, Simon Slavin wrote: > >> On 29 Mar 2015, at 5:31pm, Luuk wrote: >> >> On 19-3-2015 16:02, Simon Slavin wrote: >>> >>> One is a string. The other is a BLOB. SQLite doesn't even get as far as >>> testing the contents, it knows they are of different types. >> >>

[sqlite] Why is empty string not equal to empty blob?

2015-03-29 Thread Luuk
On 19-3-2015 16:02, Simon Slavin wrote: > > On 19 Mar 2015, at 2:56pm, Paul wrote: > >> Maybe this question was already asked and explained. >> Or maybe it is documented somewhere (could not fiund it). >> Sorry, if this is the case, but why does >> >> SELECT '' = x''; >> >> yields 0? > > One is a

[sqlite] Why is empty string not equal to empty blob?

2015-03-29 Thread Simon Slavin
> On 29 Mar 2015, at 5:31pm, Luuk wrote: > > On 19-3-2015 16:02, Simon Slavin wrote: >> >> One is a string. The other is a BLOB. SQLite doesn't even get as far as >> testing the contents, it knows they are of different types. > > C:\temp>sqlite3 > SQLite version 3.8.8.3 2015-02-25 13:29:11

[sqlite] Why is empty string not equal to empty blob?

2015-03-29 Thread Keith Medcalf
On Sunday, 29 March, 2015 10:31, Luuk inquired: >On 19-3-2015 16:02, Simon Slavin wrote: >> On 19 Mar 2015, at 2:56pm, Paul wrote: >>> Maybe this question was already asked and explained. >>> Or maybe it is documented somewhere (could not fiund it). >>> Sorry, if this is the case, but why does

[sqlite] Why is empty string not equal to empty blob?

2015-03-28 Thread Florian Weimer
* Paul: > Maybe this question was already asked and explained. > Or maybe it is documented somewhere (could not fiund it). > Sorry, if this is the case, but why does > > SELECT '' = x''; > > yields 0? In SQLite, string literals have manifest type string. This is different from SQL, where string

[sqlite] Why is empty string not equal to empty blob?

2015-03-19 Thread R.Smith
On 2015-03-19 05:32 PM, Paul wrote: >>On 19 Mar 2015, at 3:19pm, Paul wrote: >> >>> This may cause very nasty hard-to-find bugs, since SQLite allows to store >>> any content inside BLOB field: >>> >>> sqlite> create table foo(a int, b int, primary key(a, b)); >>> sqlite> insert into foo(a,

[sqlite] Why is empty string not equal to empty blob?

2015-03-19 Thread Paul
> On 19 Mar 2015, at 3:19pm, Paul wrote: > > > This may cause very nasty hard-to-find bugs, since SQLite allows to store > > any content inside BLOB field: > > > > sqlite> create table foo(a int, b int, primary key(a, b)); > > sqlite> insert into foo(a, b) VALUES(1, ''), (1, x''); > >

[sqlite] Why is empty string not equal to empty blob?

2015-03-19 Thread Paul
> On 3/19/15, Paul wrote: > > Maybe this question was already asked and explained. > > Or maybe it is documented somewhere (could not fiund it). > > Sorry, if this is the case, but why does > > > > SELECT '' = x''; > > > > yields 0? > > > > Because it has never before occurred to the

[sqlite] Why is empty string not equal to empty blob?

2015-03-19 Thread Paul
Maybe this question was already asked and explained. Or maybe it is documented somewhere (could not fiund it). Sorry, if this is the case, but why does SELECT '' = x''; yields 0? Suppose I have data in FOO table. By what means can I tell what is inside of my_blob column of FOO, when SELECT

[sqlite] Why is empty string not equal to empty blob?

2015-03-19 Thread Simon Slavin
On 19 Mar 2015, at 3:19pm, Paul wrote: > This may cause very nasty hard-to-find bugs, since SQLite allows to store any > content inside BLOB field: > > sqlite> create table foo(a int, b int, primary key(a, b)); > sqlite> insert into foo(a, b) VALUES(1, ''), (1, x''); > sqlite> select *,

[sqlite] Why is empty string not equal to empty blob?

2015-03-19 Thread Simon Slavin
On 19 Mar 2015, at 2:56pm, Paul wrote: > Maybe this question was already asked and explained. > Or maybe it is documented somewhere (could not fiund it). > Sorry, if this is the case, but why does > > SELECT '' = x''; > > yields 0? One is a string. The other is a BLOB. SQLite doesn't even

[sqlite] Why is empty string not equal to empty blob?

2015-03-19 Thread Adam Devita
As a general rule of thumb, if things are different type, they can't be equal. One already knows the column type. To compare apples to apples, one would cast to convert them. sqlite> SELECT '' = x''; 0 sqlite> SELECT cast('' as blob) = x''; 1 Perhaps some confusion comes from how numbers are

[sqlite] Why is empty string not equal to empty blob?

2015-03-19 Thread Richard Hipp
On 3/19/15, Paul wrote: > Maybe this question was already asked and explained. > Or maybe it is documented somewhere (could not fiund it). > Sorry, if this is the case, but why does > > SELECT '' = x''; > > yields 0? > Because it has never before occurred to the developers that somebody would