File tree Expand file tree Collapse file tree 3 files changed +52
-2
lines changed
Tests/ksqlDB.RestApi.Client.Tests Expand file tree Collapse file tree 3 files changed +52
-2
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,23 @@ public void Property_IgnoreField()
67
67
entityMetadata ! . FieldsMetadata . First ( c => c . MemberInfo . Name == nameof ( Payment . Description ) ) . Ignore . Should ( ) . BeTrue ( ) ;
68
68
}
69
69
70
+ [ Test ]
71
+ public void Property_IgnoreByInsertsField ( )
72
+ {
73
+ //Arrange
74
+
75
+ //Act
76
+ var fieldTypeBuilder = builder . Entity < Payment > ( )
77
+ . Property ( b => b . Description )
78
+ . IgnoreInDML ( ) ;
79
+
80
+ //Assert
81
+ fieldTypeBuilder . Should ( ) . NotBeNull ( ) ;
82
+ var entityMetadata = ( ( IMetadataProvider ) builder ) . GetEntities ( ) . FirstOrDefault ( c => c . Type == typeof ( Payment ) ) ;
83
+ entityMetadata . Should ( ) . NotBeNull ( ) ;
84
+ entityMetadata ! . FieldsMetadata . First ( c => c . MemberInfo . Name == nameof ( Payment . Description ) ) . IgnoreInDML . Should ( ) . BeTrue ( ) ;
85
+ }
86
+
70
87
[ Test ]
71
88
public void Property_HasColumnName ( )
72
89
{
@@ -233,6 +250,7 @@ public void Headers()
233
250
var metadata = entityMetadata ! . FieldsMetadata . First ( c => c . MemberInfo . Name == nameof ( Payment . Header ) ) ;
234
251
235
252
metadata . HasHeaders . Should ( ) . BeTrue ( ) ;
253
+ metadata . IgnoreInDML . Should ( ) . BeTrue ( ) ;
236
254
}
237
255
238
256
private record KeyValuePair
Original file line number Diff line number Diff line change @@ -149,6 +149,38 @@ public void Generate_UseModelBuilder_Ignore()
149
149
statement . Should ( ) . Be ( $ "INSERT INTO { insertProperties . EntityName } (Title, Id) VALUES ('Title', 1);") ;
150
150
}
151
151
152
+ private class Actor
153
+ {
154
+ [ Key ]
155
+ public int Id { get ; set ; }
156
+ public string Name { get ; set ; } = null ! ;
157
+ }
158
+
159
+ public static IEnumerable < ( IdentifierEscaping , string ) > GenerateIgnoreByInsertsTestCases ( )
160
+ {
161
+ yield return ( Never , "INSERT INTO Actors (Id) VALUES (1);" ) ;
162
+ yield return ( Keywords , "INSERT INTO Actors (Id) VALUES (1);" ) ;
163
+ yield return ( Always , "INSERT INTO `Actors` (`Id`) VALUES (1);" ) ;
164
+ }
165
+
166
+ [ TestCaseSource ( nameof ( GenerateIgnoreByInsertsTestCases ) ) ]
167
+ public void Generate_UseModelBuilder_IgnoreByInserts ( ( IdentifierEscaping escaping , string expected ) testCase )
168
+ {
169
+ //Arrange
170
+ modelBuilder . Entity < Actor > ( )
171
+ . Property ( c => c . Name )
172
+ . IgnoreInDML ( ) ;
173
+
174
+ var ( escaping , expected ) = testCase ;
175
+ var actor = new Actor { Id = 1 , Name = "E.T." } ;
176
+
177
+ //Act
178
+ var statement = new CreateInsert ( modelBuilder ) . Generate ( actor , new InsertProperties { IdentifierEscaping = escaping } ) ;
179
+
180
+ //Assert
181
+ statement . Should ( ) . Be ( expected ) ;
182
+ }
183
+
152
184
[ Test ]
153
185
public void Generate_ShouldNotPluralizeEntityName ( )
154
186
{
Original file line number Diff line number Diff line change @@ -4,14 +4,14 @@ namespace ksqlDb.RestApi.Client.Tests.Models.Movies;
4
4
5
5
public class Movie
6
6
{
7
- [ IgnoreByInserts ]
7
+ [ ksqlDB . RestApi . Client . KSql . RestApi . Statements . Annotations . Ignore ]
8
8
public long RowTime { get ; set ; }
9
9
public string Title { get ; set ; } = null ! ;
10
10
[ Key ]
11
11
public int Id { get ; set ; }
12
12
public int Release_Year { get ; set ; }
13
13
14
- [ IgnoreByInserts ]
14
+ [ ksqlDB . RestApi . Client . KSql . RestApi . Statements . Annotations . Ignore ]
15
15
public int IgnoreMe { get ; set ; }
16
16
17
17
public IEnumerable < int > ReadOnly { get ; } = new [ ] { 1 , 2 } ;
You can’t perform that action at this time.
0 commit comments