Skip to content

Commit b5219b0

Browse files
committed
Add test
1 parent f5042e6 commit b5219b0

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

DuckDB.NET.Test/TableFunctionTests.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,4 +214,31 @@ public void RegisterTableFunctionWithNullParameter()
214214

215215
data.Should().BeEquivalentTo(Enumerable.Empty<int>());
216216
}
217+
218+
[Fact]
219+
public void RegisterFunctionWithDateOnlyTimeOnlyParameters()
220+
{
221+
var dateOnly = new DateOnly(2024, 11, 6);
222+
var timeOnly = new TimeOnly(10, 30, 24);
223+
224+
Connection.RegisterTableFunction<DateOnly, TimeOnly>("demo7", (parameters) =>
225+
{
226+
var date = parameters[0].GetValue<DateOnly>();
227+
var time = parameters[1].GetValue<TimeOnly>();
228+
229+
var dateTime = date.ToDateTime(time);
230+
231+
return new TableFunction(new List<ColumnInfo>()
232+
{
233+
new ColumnInfo("foo", typeof(DateTime)),
234+
}, new[] { dateTime });
235+
}, (item, writers, rowIndex) =>
236+
{
237+
writers[0].WriteValue((DateTime)item, rowIndex);
238+
});
239+
240+
var data = Connection.Query<DateTime>("SELECT * FROM demo7('2024-11-06'::DATE, '10:30:24'::TIME);").ToList();
241+
242+
data.Should().BeEquivalentTo([new DateTime(2024, 11, 6, 10, 30, 24)]);
243+
}
217244
}

0 commit comments

Comments
 (0)