Skip to content

Commit 26f4df9

Browse files
committed
Rename class
1 parent 31be677 commit 26f4df9

File tree

5 files changed

+27
-27
lines changed

5 files changed

+27
-27
lines changed
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
# ClassMap-based Type-Safe Appender
1+
# AppenderMap-based Type-Safe Appender
22

3-
This implementation provides a type-safe way to append data to DuckDB tables using ClassMap-based mappings with automatic type validation.
3+
This implementation provides a type-safe way to append data to DuckDB tables using AppenderMap-based mappings with automatic type validation.
44

55
## Problem Solved
66

7-
The original issue was that users could accidentally append values with mismatched types (e.g., `decimal` to `REAL` column), causing silent data corruption. The ClassMap approach validates types against actual column types from the database.
7+
The original issue was that users could accidentally append values with mismatched types (e.g., `decimal` to `REAL` column), causing silent data corruption. The AppenderMap approach validates types against actual column types from the database.
88

99
## How It Works
1010

11-
### 1. Define a ClassMap
11+
### 1. Define an AppenderMap
1212

13-
Create a ClassMap that defines property mappings in column order:
13+
Create an AppenderMap that defines property mappings in column order:
1414

1515
```csharp
16-
public class PersonMap : DuckDBClassMap<Person>
16+
public class PersonMap : DuckDBAppenderMap<Person>
1717
{
1818
public PersonMap()
1919
{
@@ -61,7 +61,7 @@ The mapped appender retrieves actual column types from the database and validate
6161

6262
### 3. **Support for Default and Null Values**
6363
```csharp
64-
public class MyMap : DuckDBClassMap<MyData>
64+
public class MyMap : DuckDBAppenderMap<MyData>
6565
{
6666
public MyMap()
6767
{

DuckDB.NET.Data/DuckDBConnection.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,43 +187,43 @@ string GetTableName()
187187
}
188188

189189
/// <summary>
190-
/// Creates a type-safe appender using a ClassMap for property-to-column mappings.
190+
/// Creates a type-safe appender using an AppenderMap for property-to-column mappings.
191191
/// </summary>
192192
/// <typeparam name="T">The type to append</typeparam>
193-
/// <typeparam name="TMap">The ClassMap type defining the mappings</typeparam>
193+
/// <typeparam name="TMap">The AppenderMap type defining the mappings</typeparam>
194194
/// <param name="table">The table name</param>
195195
/// <returns>A type-safe mapped appender</returns>
196196
public DuckDBMappedAppender<T, TMap> CreateAppender<T, TMap>(string table)
197-
where TMap : Mapping.DuckDBClassMap<T>, new()
197+
where TMap : Mapping.DuckDBAppenderMap<T>, new()
198198
{
199199
return CreateAppender<T, TMap>(null, null, table);
200200
}
201201

202202
/// <summary>
203-
/// Creates a type-safe appender using a ClassMap for property-to-column mappings.
203+
/// Creates a type-safe appender using an AppenderMap for property-to-column mappings.
204204
/// </summary>
205205
/// <typeparam name="T">The type to append</typeparam>
206-
/// <typeparam name="TMap">The ClassMap type defining the mappings</typeparam>
206+
/// <typeparam name="TMap">The AppenderMap type defining the mappings</typeparam>
207207
/// <param name="schema">The schema name</param>
208208
/// <param name="table">The table name</param>
209209
/// <returns>A type-safe mapped appender</returns>
210210
public DuckDBMappedAppender<T, TMap> CreateAppender<T, TMap>(string? schema, string table)
211-
where TMap : Mapping.DuckDBClassMap<T>, new()
211+
where TMap : Mapping.DuckDBAppenderMap<T>, new()
212212
{
213213
return CreateAppender<T, TMap>(null, schema, table);
214214
}
215215

216216
/// <summary>
217-
/// Creates a type-safe appender using a ClassMap for property-to-column mappings.
217+
/// Creates a type-safe appender using an AppenderMap for property-to-column mappings.
218218
/// </summary>
219219
/// <typeparam name="T">The type to append</typeparam>
220-
/// <typeparam name="TMap">The ClassMap type defining the mappings</typeparam>
220+
/// <typeparam name="TMap">The AppenderMap type defining the mappings</typeparam>
221221
/// <param name="catalog">The catalog name</param>
222222
/// <param name="schema">The schema name</param>
223223
/// <param name="table">The table name</param>
224224
/// <returns>A type-safe mapped appender</returns>
225225
public DuckDBMappedAppender<T, TMap> CreateAppender<T, TMap>(string? catalog, string? schema, string table)
226-
where TMap : Mapping.DuckDBClassMap<T>, new()
226+
where TMap : Mapping.DuckDBAppenderMap<T>, new()
227227
{
228228
var appender = CreateAppender(catalog, schema, table);
229229
return new DuckDBMappedAppender<T, TMap>(appender);

DuckDB.NET.Data/DuckDBMappedAppender.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
namespace DuckDB.NET.Data;
88

99
/// <summary>
10-
/// A type-safe appender that uses ClassMap to validate type mappings.
10+
/// A type-safe appender that uses AppenderMap to validate type mappings.
1111
/// </summary>
1212
/// <typeparam name="T">The type being appended</typeparam>
13-
/// <typeparam name="TMap">The ClassMap type defining the mappings</typeparam>
14-
public class DuckDBMappedAppender<T, TMap> : IDisposable where TMap : DuckDBClassMap<T>, new()
13+
/// <typeparam name="TMap">The AppenderMap type defining the mappings</typeparam>
14+
public class DuckDBMappedAppender<T, TMap> : IDisposable where TMap : DuckDBAppenderMap<T>, new()
1515
{
1616
private readonly DuckDBAppender appender;
1717
private readonly List<IPropertyMapping<T>> mappings;
@@ -27,13 +27,13 @@ internal DuckDBMappedAppender(DuckDBAppender appender)
2727
// Validate mappings match the table structure
2828
if (mappings.Count == 0)
2929
{
30-
throw new InvalidOperationException($"ClassMap {typeof(TMap).Name} has no property mappings defined");
30+
throw new InvalidOperationException($"AppenderMap {typeof(TMap).Name} has no property mappings defined");
3131
}
3232

3333
var columnTypes = appender.LogicalTypes;
3434
if (mappings.Count != columnTypes.Count)
3535
{
36-
throw new InvalidOperationException($"ClassMap {typeof(TMap).Name} has {mappings.Count} mappings but table has {columnTypes.Count} columns");
36+
throw new InvalidOperationException($"AppenderMap {typeof(TMap).Name} has {mappings.Count} mappings but table has {columnTypes.Count} columns");
3737
}
3838

3939
for (int index = 0; index < mappings.Count; index++)

DuckDB.NET.Data/Mapping/DuckDBClassMap.cs renamed to DuckDB.NET.Data/Mapping/DuckDBAppenderMap.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
namespace DuckDB.NET.Data.Mapping;
77

88
/// <summary>
9-
/// Base class for defining mappings between .NET classes and DuckDB table columns.
9+
/// Base class for defining mappings between .NET classes and DuckDB table columns for appender operations.
1010
/// </summary>
1111
/// <typeparam name="T">The type to map</typeparam>
12-
public abstract class DuckDBClassMap<T>
12+
public abstract class DuckDBAppenderMap<T>
1313
{
1414
/// <summary>
1515
/// Gets the property mappings defined for this class map.

DuckDB.NET.Test/DuckDBMappedAppenderTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public class Person
1616
public DateTime BirthDate { get; set; }
1717
}
1818

19-
// ClassMap for Person - matches the example from the comment
20-
public class PersonMap : DuckDBClassMap<Person>
19+
// AppenderMap for Person - matches the example from the comment
20+
public class PersonMap : DuckDBAppenderMap<Person>
2121
{
2222
public PersonMap()
2323
{
@@ -66,7 +66,7 @@ public void MappedAppender_ValidatesTypeMatching()
6666
}
6767

6868
// Example with type mismatch - should throw
69-
public class WrongTypeMap : DuckDBClassMap<Person>
69+
public class WrongTypeMap : DuckDBAppenderMap<Person>
7070
{
7171
public WrongTypeMap()
7272
{
@@ -98,7 +98,7 @@ public class PersonWithDefaults
9898
public string Name { get; set; } = string.Empty;
9999
}
100100

101-
public class PersonWithDefaultsMap : DuckDBClassMap<PersonWithDefaults>
101+
public class PersonWithDefaultsMap : DuckDBAppenderMap<PersonWithDefaults>
102102
{
103103
public PersonWithDefaultsMap()
104104
{

0 commit comments

Comments
 (0)