Closed mikeTWC1984 closed 1 year ago
@mikeTWC1984 Can you add a test that shows what issue this PR solves?
It lets loading reader data into datatable. Possible test is below. Without GetSchemaTable method dt.Load(reader) would throw an exception.
[Fact]
public void LoadDataTable()
{
using var connection = new DuckDBConnection("DataSource=:memory:");
connection.Open();
var duckDbCommand = connection.CreateCommand();
duckDbCommand.CommandText = "select 1 as num, 'text' as str, now() as tme";
var reader = duckDbCommand.ExecuteReader();
var dt = new DataTable()
dt.Load(reader)
dt.Rows.Count.Should().Be(1)
}
Can you add that test to the PR?
Just added
just fixed missing semicolon
I see test failing because "now()" returns a timestamp with milliseconds, by some reason reader.GetDateTime method can't handle it. If I use timestamp from literal without ms, (e.g. "TIMESTAMP '1992-09-20 20:38:40'") it works. I can also get string value from "now" ( reader.GetString) and cast it to ts.
@mikeTWC1984 Yes, please replace now
with some literal and create an issue for milliseconds issue.
This should allow to load DataTable from Reader. https://github.com/Giorgi/DuckDB.NET/issues/65