[Mono-list] Bug (?) in SqliteDataReader
Nikki Locke
nikki at trumphurst.com
Mon May 15 07:30:04 EDT 2006
I use the Sqlite database under both Windows and Linux. Under Windows, if I
have a date or datetime field, then row data returned from a query on that
field is returned as a DateTime. Under Linux, it is returned as a string.
Worse, the string format is ambiguous (is it DD/MM/YYYY or MM/DD/YYYY?).
This appears to be a bug in SqliteDataReader.GetSchemaTable, which sets
schemaRow["DataType"] to typeof(string) for every field, regardless.
I have copied the entire
mcs/class/Mono.Data.SqliteClient/Mono.Data.SqliteClient diretory into my
project, applied the fix below, and recompiled, and it now works as I would
expect.
Is this a reasonable patch? If it is, how should I go about getting it
included in the mono official sources?
Around line 278, replace...
schemaRow["DataType"] = typeof(string);
with
switch(GetDataTypeName(i)) {
case "int":
case "integer":
schemaRow["DataType"] = typeof(int);
break;
case "date":
case "datetime":
schemaRow["DataType"] = typeof(DateTime);
break;
default:
schemaRow["DataType"] = typeof(string);
break;
}
--
Nikki Locke, Trumphurst Ltd. PC & Unix consultancy & programming
http://www.trumphurst.com/
More information about the Mono-list
mailing list