[Mono-list] Bug (?) in SqliteDataReader

Jonathan Gilbert 2a5gjx302 at sneakemail.com
Thu May 18 10:45:41 EDT 2006

At 06:53 PM 17/05/2006 -0400, Joshua Tauberer wrote:
>Nikki Locke wrote:
>> What about putting in some type checking when the data is _written_ to the 
>> database, instead? OK, it wouldn't stop exceptions being thrown if the
>> was written by a some other app, but at least it would make things work 
>> consistently.
>I don't think there should be a database that can't be read using any
>method, even if it wasn't created with Mono.Data.SqliteClient and even
>if it has crazy nonuniform data in columns.

What about making SQLite type "safety" an optional feature, configured in
the connection string, so that when enabled, the GetSchemaTable method
returns the types asreported by SQLite, but by default (with a plain,
standard connection string) it returns all columns as 'String'? This is
especilaly attractive if there is some way to indicate this in the
connection string that other providers (e.g. Finisar) will simply ignore.
That way, if you know & trust the database, you can enable the type
conversions, but with the knowledge that the database could be "corrupt"
w.r.t. the column types, resulting in exceptions that are outside of your
control. If you don't trust the database, then you can simply get strings
back and go from there :-)

A quick glance at Connection.cs in the Finisar source code
(http://tinyurl.com/nt4we) and the mono SqliteClient source code
(http://tinyurl.com/rrpcb) shows that mono will simply ignore any
parameters in the connection string, as long as they're well-formed
("Name=Value"), and while Finisar will complain about any parameter name it
doesn't know, it silently allows parameter *values* it doesn't know about.
Finisar has a parameter called "Compatibility", so perhaps this could be
hijacked for this purpose:

string conn_str = "Data

Of course, Mono.Data.SqliteClient uses "URI" in place of "Data Source", but
perhaps "Data Source" could be added to Mono.Data.SqliteClient; then, the
above connection string would work just fine in both Finisar.Sqlite and
Mono.Data.SqliteClient :-)

Note that if a user wants one of the other Finisar "Compatibility" options,
they can simply include the "Compatibility" parameter more than once.

Another option -- not mutually exclusive -- might be to make any fields of
a record which fail to parse into DBNulls. Of course, this could only
properly be done on fields not marked as "NOT NULL", but it would be a
useful alternative to throwing exceptions...

Jonathan Gilbert

More information about the Mono-list mailing list