Skip to content

Commit 54109ae

Browse files
committed
[ksqlDb.RestApi.Client]: added the IgnoreInDDL function to the Fluent API doc sections #93
1 parent c09bddd commit 54109ae

File tree

2 files changed

+66
-2
lines changed

2 files changed

+66
-2
lines changed

docs/modelbuilder.md

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,13 +349,13 @@ var restApiClientOptions = new KSqlDBRestApiClientOptions
349349
ShouldPluralizeFromItemName = false,
350350
};
351351

352-
var restApiClient = new KSqlDbRestApiClient(httpClientFactory, restApiClientOptions);
353-
354352
var modelBuilder = new ModelBuilder();
355353
modelBuilder.Entity<Actor>()
356354
.Property(c => c.Name)
357355
.IgnoreInDML();
358356

357+
var restApiClient = new KSqlDbRestApiClient(httpClientFactory, modelBuilder, restApiClientOptions);
358+
359359
var actor = new Actor { Id = 1, Name = "Matthew David McConaughey" };
360360

361361
var ksql = restApiClient.ToInsertStatement(actor);
@@ -367,3 +367,65 @@ INSERT INTO Actor (Id) VALUES (1);
367367
```
368368

369369
`WithHeaders` internally automatically marks the property to be ignored in DML statements.
370+
371+
372+
### IgnoreInDDL
373+
**v6.4.0**
374+
375+
The purpose of the `IgnoreInDDL` function is to exclude specific fields from CREATE statements.
376+
377+
```C#
378+
using System.ComponentModel.DataAnnotations;
379+
380+
public record Record
381+
{
382+
public int Id { get; set; }
383+
384+
public string Title { get; set; }
385+
386+
[PseudoColumn]
387+
public long RowTime { get; set; }
388+
}
389+
```
390+
391+
```C#
392+
using ksqlDb.RestApi.Client.FluentAPI.Builders;
393+
using ksqlDB.RestApi.Client.KSql.Query.Context;
394+
using ksqlDB.RestApi.Client.KSql.RestApi;
395+
using ksqlDB.RestApi.Client.KSql.RestApi.Http;
396+
397+
var ksqlDbUrl = "http://localhost:8088";
398+
399+
var httpClientFactory = new HttpClientFactory(new HttpClient() { BaseAddress = new Uri(ksqlDbUrl) });
400+
401+
var restApiClientOptions = new KSqlDBRestApiClientOptions
402+
{
403+
ShouldPluralizeFromItemName = false,
404+
};
405+
406+
var modelBuilder = new ModelBuilder();
407+
modelBuilder.Entity<Record>()
408+
.HasKey(c => c.Id);
409+
410+
modelBuilder.Entity<Record>()
411+
.Property(c => c.RowTime)
412+
.IgnoreInDDL();
413+
414+
var restApiClient = new KSqlDbRestApiClient(httpClientFactory, modelBuilder, restApiClientOptions);
415+
416+
EntityCreationMetadata metadata = new(kafkaTopic: nameof(Record))
417+
{
418+
Partitions = 3,
419+
Replicas = 3
420+
};
421+
422+
var httpResponseMessage = await restApiClient.CreateOrReplaceStreamAsync<Record>(metadata);
423+
```
424+
425+
Generated DDL:
426+
```SQL
427+
CREATE OR REPLACE STREAM Record (
428+
Id INT KEY,
429+
Title VARCHAR
430+
) WITH ( KAFKA_TOPIC='Record', VALUE_FORMAT='Json', PARTITIONS='3', REPLICAS='3' );
431+
```

ksqlDb.RestApi.Client/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
# 6.4.0
44
- added the `IgnoreInDML` function to the Fluent API to exclude fields from INSERT statements #90 (proposed by @mrt181)
5+
- added the `IgnoreInDDL` function to the Fluent API to exclude fields from INSERT statements with a corresponding `IgnoreInDDLAttribute` #93
56
- added `IgnoreAttribute` to prevent properties or fields from being included in both DDL and DML statement
67
- `Headers` property was marked as obsolete in the `Record` type
78

89
## BugFix
910
- `IgnoreByInsertsAttribute` no longer excludes fields or properties from DDL statements. For this purpose, a new `IgnoreAttribute` has been introduced.
11+
- the `Record` type's fields `RowOffset` and `RowPartition` were decorated with `IgnoreAttribute` instead of `IgnoreByInsertsAttribute`, and `RowTime` was decorated with `IgnoreInDDLAttribute` instead of `IgnoreByInsertsAttribute`.
1012

1113
# 6.3.0
1214
- added `AsStruct` function to the Fluent API for marking fields as ksqldb `STRUCT` types #89 (proposed by @mrt181)

0 commit comments

Comments
 (0)