[Mono-list] Bug (?) in SqliteDataReader

Joshua Tauberer tauberer at for.net
Thu May 25 16:12:43 EDT 2006


Nikki Locke wrote:
> In GetSchemaTable, you claim all the fields are strings. However, in 
> ReadpVm you go to some trouble to return the fields as other types. 
> This strikes me as inconsistent!

No argument there.  We've ended up in a strange situation.

> Having looked at the source, I see that the justification for 
> treating integer values in DateTime columns as FileTimes is that is
> how they are treated in parameters.

That's right.

> So I tried some code to insert a DateTime in a parameter. I used the
> following code...
> 
> string sql = "insert into tester (testdate) values (?)";

If you use a named parameter, i.e. ?var, it should work.  Unnamed
parameters weren't implemented.  (I just committed a fix for that.)

> Do you have the Mono debugger working at all? Any hints how I can get
>  it working?

Never used it...

> I think that, in order to avoid breaking existing code, the default should be much 
> as it is now, EXCEPT do not convert strings to DateTimes in ReadpVm 
> (SqliteDataReader, about line 188). That would stop it giving an exception when a 
> string is inserted in a DateTime. It would also prevent the DateTime getting 
> converted back into a string by the DataTable (which is what makes the original 
> value unrecoverable).

Well, what makes the original value unrecoverable is an independent bug
in DateTime.Parse (for reference: it is parsing strings like 02/01/2005
with the U.S. format when the current culture is UK).  Importantly,
knowing where the bug is means the workaround is in your own code that
parses the contents of the DataTable.

The second work-around was to have GetSchemaTable return DateTime where
possible, so that the DateTimes the SqliteClient is already parsing
don't get converted back into strings that need parsing in user code.
Despite my earlier objections, this seems like a reasonable thing to do.

The third word-around is to stop parsing strings to DateTimes in
SqliteClient.  Given this changes the data types people get back from
the SqliteDataReader, I'm very hesitant to change this except through a
connection string parameter.

But these are all workarounds and it would be nice to just fix DateTime
before proceeding.

-- 
- Joshua Tauberer

http://taubz.for.net

"Unfortunately, we're having this discussion. It's too bad,
because guess who listens to the discussion: the enemy."


More information about the Mono-list mailing list