npgsql/Npgsql — pull request #362 by Emill (2014-09-21 20:37:22+00:00)
Title: Data types and parameter fixes

Hi. I have created a fix for the parameter issues + BitString issues.

This fix make these behaviours:

The type of the parameter can either be explicitly set or automatically infered when a value is set.
If the type is explicitly set to NpgsqlDbType.Unknown or DbType.Object, no casting will be made. Instead, the value is written as a literal string. For prepared queries, the value is also sent as a literal string (.ToString() on the value), hoping the backend can take care of it.
Otherwise, casting will always be made.

Until a value has been set (or only null has been set before something else), the type is initially NpgsqlDbType.Unknown instead of text, as it was before.

The char datatype if used as parameter type doesn't truncate the string anymore to one character.

I added a "varbit" datatype which maps to BitString.
In the case the user uses "bit(1)", a bool will be returned from the database instead of BitString. Array of bit(1) means a bool[].
Before, BitString didn't work well. If used as parameter, the bit string was truncated to one bit. I've fixed this and also implemented binary encoding for use with prepared queries (didn't work before at all).

Tell me what you think :)
I think this fix makes the parameter handling and data type handling more reasonable.

It should fix https://github.com/npgsql/Npgsql/issues/146, https://github.com/npgsql/Npgsql/issues/335, https://github.com/npgsql/Npgsql/issues/361

Commit log:
BitString works better now.
Bit(1) uses bool and otherwise BitString is used.
Casts are used as long as the type is not explicitly set to NpgsqlDbType.Unknown or DbType.Object. NpgsqlDbType.Unknown is now default for parameters instead of text.
Unknown parameters are always sent as text on prepared queries.
DbType.Time is now mapped to interval.
Output parameters now work for prepared queries.