Giorgi / DuckDB.NET

Bindings and ADO.NET Provider for DuckDB
https://duckdb.net
MIT License
356 stars 62 forks source link

Some Dapper issues #38

Closed pkese closed 2 years ago

pkese commented 2 years ago

I've found that it's easy to break Dapper and I'm including a script to reproduce it here. Works fine with Sqlite.

Not sure about priority of this ... do we even care about Dapper at this point in time?.

#!/usr/bin/env -S dotnet fsi

#r "nuget: DuckDB.NET.Data, 0.4.0"

// or include path to DuckDB.NET.Data build and load the .dll directly
//#I "../org/DuckDB.NET/DuckDB.NET.Data/bin/Debug/netstandard2.0/"
//#r "DuckDB.NET.Data.dll"

// also put libduckdb.{dll|so} someplace (e.g. in current directory) and point to it here
#I "." 

#r "nuget: Microsoft.Data.Sqlite, 6.0.6"
#r "nuget: Dapper, 2.0.123"

open DuckDB.NET.Data
open Microsoft.Data.Sqlite
open Dapper
open System.Data

// test with either DuckDb or Sqlite
let conn =
    //new SqliteConnection("Data Source=:memory:") :> IDbConnection
    new DuckDBConnection("Data Source=:memory:") :> IDbConnection

conn.Open()
conn.Execute("CREATE TABLE test (id INTEGER, name VARCHAR)") |> ignore

[<CLIMutable>] type Row = { id:int; name:string }

conn.Query<Row>("SELECT * FROM test")
|> Seq.length
|> printfn "initial rows: %d"

conn.Execute("INSERT INTO test (id,name) VALUES (123,'test')") |> ignore

for row in conn.Query<Row>("SELECT * FROM test") do
    printfn $"after insertion: {row.id} {row.name}"
Giorgi commented 2 years ago

This should be fixed in 8eddf5217a8b99dd8592d46a0bafc8e8be6de25f