Using System.Data.SQLite , I create a table with unsigned integer columns:
@"CREATE TABLE widgets (" + @"id unsigned integer(10) PRIMARY KEY, " + @"fkey unsigned integer(10), " + ...
and then paste the values ββlike
INSERT INTO widgets (id, fkey, ...) VALUES (4294967295, 3456, ...
However, looking through the rows and columns of this table, I found that row["id"] is of type System.Int32 (not UInt32 ), and it is not surprising that 4294967295 is interpreted as -1. In fact, all unsigned int fields in the table (and not just the primary key identifier are incorrectly entered as System.Int32 )
Meanwhile, a SQLite type specification says that integers are stored in 1, 2, 3, 4, 6, or 8 bytes, depending on the value. 4294967295 = 0xFFFFFFFF fits in just four bytes. This also contradicts the so-called "dynamic typing" of SQLite. When I insert more than 4294967295 positive values, the type remains System.Int32 .
Is this a bug or a function?
PS1:
my table contains 1 row with the column id = 2 ^ 32-1 = 4294967295 (or more), and I print the types of all columns with
public void PrintDataTypes(DataTable dt) { foreach (DataRow row in dt.Rows) { foreach (DataColumn col in dt.Columns) Console.WriteLine("name={0}, type={1}", col.ToString(), row[col].GetType().ToString()); return;
And I always get
name=id, type=System.Int32 name=fkey, type=System.Int32 ...