• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Giorgi / DuckDB.NET / 21786556530

07 Feb 2026 08:39PM UTC coverage: 89.155% (-0.07%) from 89.223%
21786556530

push

github

Giorgi
Added support for clearing in-progress adapter

Requires DuckDB 1.5

1199 of 1393 branches covered (86.07%)

Branch coverage included in aggregate %.

6 of 8 new or added lines in 1 file covered. (75.0%)

193 existing lines in 43 files now uncovered.

2336 of 2572 relevant lines covered (90.82%)

557295.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

56.76
/DuckDB.NET.Data/Mapping/DuckDBAppenderMap.cs
1
namespace DuckDB.NET.Data.Mapping;
2

3
/// <summary>
4
/// Base class for defining mappings between .NET classes and DuckDB table columns for appender operations.
5
/// </summary>
6
/// <typeparam name="T">The type to map</typeparam>
7
public abstract class DuckDBAppenderMap<T>
8
{
9
    /// <summary>
10
    /// Gets the property mappings defined for this class map.
11
    /// </summary>
12
    internal List<IPropertyMapping<T>> PropertyMappings { get; } = new(8);
54✔
13

14
    /// <summary>
15
    /// Maps a property to the next column in sequence.
16
    /// </summary>
17
    /// <typeparam name="TProperty">The property type</typeparam>
18
    /// <param name="getter">Function to get the property value</param>
19
    protected void Map<TProperty>(Func<T, TProperty> getter)
20
    {
21
        var mapping = new PropertyMapping<T, TProperty>
30✔
22
        {
30✔
23
            PropertyType = typeof(TProperty),
30✔
24
            Getter = getter,
30✔
25
            MappingType = PropertyMappingType.Property
30✔
26
        };
30✔
27

28
        PropertyMappings.Add(mapping);
30✔
29
    }
30✔
30

31
    /// <summary>
32
    /// Adds a default value for the next column.
33
    /// </summary>
34
    protected void DefaultValue()
35
    {
36
        var mapping = new DefaultValueMapping<T>
3✔
37
        {
3✔
38
            PropertyType = typeof(object),
3✔
39
            MappingType = PropertyMappingType.Default
3✔
40
        };
3✔
41

42
        PropertyMappings.Add(mapping);
3✔
43
    }
3✔
44

45
    /// <summary>
46
    /// Adds a null value for the next column.
47
    /// </summary>
48
    protected void NullValue()
49
    {
50
        var mapping = new NullValueMapping<T>
3✔
51
        {
3✔
52
            PropertyType = typeof(object),
3✔
53
            MappingType = PropertyMappingType.Null
3✔
54
        };
3✔
55

56
        PropertyMappings.Add(mapping);
3✔
57
    }
3✔
58
}
59

60
internal enum PropertyMappingType
61
{
62
    Property,
63
    Default,
64
    Null
65
}
66

67
internal interface IPropertyMapping<T>
68
{
69
    Type PropertyType { get; }
70
    PropertyMappingType MappingType { get; }
71
    IDuckDBAppenderRow AppendToRow(IDuckDBAppenderRow row, T record);
72
}
73

74
internal sealed class PropertyMapping<T, TProperty> : IPropertyMapping<T>
75
{
76
    public Type PropertyType { get; set; } = typeof(object);
90✔
77
    public Func<T, TProperty> Getter { get; set; } = _ => default!;
96✔
78
    public PropertyMappingType MappingType { get; set; }
57✔
79

80
    public IDuckDBAppenderRow AppendToRow(IDuckDBAppenderRow row, T record)
81
    {
82
        var value = Getter(record);
36✔
83

84
        if (value is null)
36!
85
        {
UNCOV
86
            return row.AppendNullValue();
×
87
        }
88

89
        return value switch
36!
90
        {
36✔
91
            // Reference types
36✔
92
            string v => row.AppendValue(v),
12✔
93

36✔
94
            // Value types
36✔
UNCOV
95
            bool v => row.AppendValue(v),
×
UNCOV
96
            sbyte v => row.AppendValue(v),
×
UNCOV
97
            short v => row.AppendValue(v),
×
98
            int v => row.AppendValue(v),
12✔
UNCOV
99
            long v => row.AppendValue(v),
×
100
            byte v => row.AppendValue(v),
×
101
            ushort v => row.AppendValue(v),
×
102
            uint v => row.AppendValue(v),
×
UNCOV
103
            ulong v => row.AppendValue(v),
×
104
            float v => row.AppendValue(v),
6✔
105
            double v => row.AppendValue(v),
×
106
            decimal v => row.AppendValue(v),
×
107
            DateTime v => row.AppendValue(v),
6✔
108
            DateTimeOffset v => row.AppendValue(v),
×
UNCOV
109
            TimeSpan v => row.AppendValue(v),
×
110
            Guid v => row.AppendValue(v),
×
111
            BigInteger v => row.AppendValue(v),
×
UNCOV
112
            DuckDBDateOnly v => row.AppendValue(v),
×
113
            DuckDBTimeOnly v => row.AppendValue(v),
×
114
            DateOnly v => row.AppendValue(v),
×
115
            TimeOnly v => row.AppendValue(v),
×
116

36✔
117
            _ => throw new NotSupportedException($"Type {typeof(TProperty).Name} is not supported for appending")
×
118
        };
36✔
119
    }
120
}
121

122
internal sealed class DefaultValueMapping<T> : IPropertyMapping<T>
123
{
124
    public Type PropertyType { get; set; } = typeof(object);
6✔
125
    public PropertyMappingType MappingType { get; set; }
6✔
126

127
    public IDuckDBAppenderRow AppendToRow(IDuckDBAppenderRow row, T record)
128
    {
129
        return row.AppendDefault();
6✔
130
    }
131
}
132

133
internal sealed class NullValueMapping<T> : IPropertyMapping<T>
134
{
135
    public Type PropertyType { get; set; } = typeof(object);
6✔
136
    public PropertyMappingType MappingType { get; set; }
6✔
137

138
    public IDuckDBAppenderRow AppendToRow(IDuckDBAppenderRow row, T record)
139
    {
140
        return row.AppendNullValue();
6✔
141
    }
142
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc