views:

195

answers:

1

In one SqLite table, I have a BLOB column for saving images (or binary data as a matter of fact). The table is Documents.

Strangely, in Subsonic's ActiveRecord's Documents class, the type of that column shows as STRING which doesn't make sense. It should be byte array. Right?

What am I missing here? How do I map SqLite BLOB column in Subsonic?

+1  A: 

SQLite, believe it or not, does not have typed columns. Any data can be stored in any column (except INTEGER PK), regardless of how that column was declared. Each column has an "affinity", and that's what's reported to front ends that query the column's data type. In SQLite, the affinity for a BLOB column is returned as TEXT.

You can read more about it here.

Larry Lustig
Since Subsonic is showing BLOB as STRING type, does it mean that I have to save image as text data.And on way out, get that text data and convert into Byte array ro something?Also, it means that no point in using BLOB type in SqLite . Use STRING type instead. Right?
AJ
Nope, you should be able to save the BLOB to that column just fine. In fact, you can save a BLOB to a column that's "defined" as float if you want. SQLite doesn't care. It's the only database like that that I know of (they only one *they* know of too, judging from the write-up at the link I posted). I don't know anything about Subsonic — perhaps it will get confused. But you can definitely store your BLOB data in that apparently TEXT column.
Larry Lustig
that would have worked but I modified SQLite.ttinclude GetSysType method to include blob type. Now blob will be treated as byte[] by subsonic. Excerpt as follow: case "image": case "blob": case "binary": case "tinyint": case "varbinary": sysType= "byte[]";HTH, Pankaj
AJ