File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 1
- using System . Linq . Expressions ;
1
+ using ksqlDB . RestApi . Client . Infrastructure . Extensions ;
2
+ using ksqlDB . RestApi . Client . KSql . RestApi . Validation ;
2
3
using ksqlDb . RestApi . Client . Metadata ;
3
4
4
5
namespace ksqlDb . RestApi . Client . FluentAPI . Builders
@@ -68,8 +69,15 @@ public IFieldTypeBuilder<TProperty> AsStruct()
68
69
return this ;
69
70
}
70
71
72
+ private readonly PseudoColumnValidator pseudoColumnValidator = new ( ) ;
73
+
71
74
public IFieldTypeBuilder < TProperty > AsPseudoColumn ( )
72
75
{
76
+ var columnName = fieldMetadata . ColumnName ?? fieldMetadata . MemberInfo . GetMemberName ( default ( EntityMetadata ? ) ) ;
77
+
78
+ if ( ! pseudoColumnValidator . IsValid ( columnName ) )
79
+ throw new InvalidOperationException ( $ "{ columnName } is not a valid pseudocolumn name") ;
80
+
73
81
fieldMetadata . IsPseudoColumn = true ;
74
82
return this ;
75
83
}
Original file line number Diff line number Diff line change
1
+ using ksqlDb . RestApi . Client . KSql . RestApi . Parsers ;
2
+ using ksqlDB . RestApi . Client . Infrastructure . Extensions ;
3
+
4
+ namespace ksqlDB . RestApi . Client . KSql . RestApi . Validation
5
+ {
6
+ internal class PseudoColumnValidator
7
+ {
8
+ private readonly string [ ] allowedPseudoColumnNames =
9
+ [
10
+ "Headers" . ToUpper ( ) ,
11
+ nameof ( SystemColumns . ROWOFFSET ) . ToUpper ( ) ,
12
+ nameof ( SystemColumns . ROWPARTITION ) . ToUpper ( ) ,
13
+ nameof ( SystemColumns . ROWTIME ) . ToUpper ( )
14
+ ] ;
15
+
16
+ internal bool IsValid ( string columnName )
17
+ {
18
+ return columnName . ToUpper ( ) . IsOneOfFollowing ( allowedPseudoColumnNames ) ;
19
+ }
20
+ }
21
+ }
You can’t perform that action at this time.
0 commit comments