Dapper icon indicating copy to clipboard operation
Dapper copied to clipboard

SQLite, Wrong bool conversion

Open Yari27 opened this issue 2 years ago • 3 comments

Column type is BOOLEAN. SQLiteConnection class return value "True" but Dapper cannot convert it to a bool value. Please fix this.

Yari27 avatar Mar 28 '23 19:03 Yari27

Hi,

Checked with Dapper 2.0.143 and System.Data.SQLite 4.2.2. Works as expected.

using System.Data.SQLite;
using Dapper;


var connection = new SQLiteConnection("Data Source=:memory:;Version=3;New=True;");
connection.Open();

// Init
await connection.ExecuteAsync(@"create table test (id int, bool_field boolean)");
await connection.ExecuteAsync(@"insert into test (id, bool_field) values (1, 1), (2, 0)");

// Assert
foreach (var val1 in await connection.QueryAsync<bool>("select bool_field from test"))
{
    Console.WriteLine($"{val1}");
}
connection.Close();

/* Console output
True
False

*/

pavelpykhtin avatar Jun 27 '23 14:06 pavelpykhtin

I find SQLite only in version 1.0.118 devenv_2023-06-27_19-04-18 Where you find 4.2.2 ?

But it seems to work.

Yari27 avatar Jun 27 '23 17:06 Yari27

You're right. I used version 1.0.118. 4.2.2 is the version of Dapper.Extensions.SQLite.

pavelpykhtin avatar Jun 28 '23 09:06 pavelpykhtin