@@ -759,29 +759,28 @@ public void ModelBuilder_IgnoreProperty()
759
759
) WITH ( KAFKA_TOPIC='{ nameof ( Poco ) } ', VALUE_FORMAT='Json', PARTITIONS='1', REPLICAS='1' );" . ReplaceLineEndings ( ) ) ;
760
760
}
761
761
762
- private class PocoWithNullable : Poco
762
+ private class Poco2 : Poco
763
763
{
764
764
public InnerPoco InnerPoco { get ; init ; }
765
765
}
766
766
767
- private class PocoWithNullable2 : Poco
767
+ private class Poco3 : Poco
768
768
{
769
769
public InnerPoco InnerPoco { get ; init ; }
770
770
}
771
771
772
- private class PocoWithNullable3 : Poco
772
+ private class Poco4 : Poco
773
773
{
774
774
public InnerPoco InnerPoco { get ; init ; }
775
775
}
776
776
777
- private class PocoWithNullable4 : Poco
777
+ private class Poco5 : Poco
778
778
{
779
779
public InnerPoco InnerPoco { get ; init ; }
780
780
}
781
781
782
782
private class OuterPoco : Poco
783
783
{
784
-
785
784
public InnerPoco InnerPoco { get ; init ; }
786
785
}
787
786
@@ -796,17 +795,61 @@ private class InnerPoco2
796
795
public int Value { get ; init ; }
797
796
}
798
797
798
+ private class OuterPoco2 : Poco
799
+ {
800
+ public InnerPoco3 InnerPoco { get ; init ; }
801
+ }
802
+
803
+ private class InnerPoco3
804
+ {
805
+ public int Value { get ; init ; }
806
+ public PocoEnum ? ValueNullable { get ; init ; }
807
+ }
808
+
809
+ private enum PocoEnum
810
+ {
811
+ MemberA ,
812
+ }
813
+
814
+ [ Test ]
815
+ public void ModelBuilder_SetTypeOfNullableEnum ( )
816
+ {
817
+ //Arrange
818
+ modelBuilder . Entity < OuterPoco2 > ( )
819
+ . HasKey ( x => x . Id ) ;
820
+ modelBuilder . Entity < OuterPoco2 > ( )
821
+ . Property ( c => c . InnerPoco ) . AsStruct ( ) ;
822
+
823
+ var statementContext = new StatementContext
824
+ {
825
+ CreationType = CreationType . CreateOrReplace ,
826
+ KSqlEntityType = KSqlEntityType . Table ,
827
+ } ;
828
+
829
+ creationMetadata . KafkaTopic = nameof ( Poco ) ;
830
+
831
+ //Act
832
+ string statement = new CreateEntity ( modelBuilder ) . Print < OuterPoco2 > ( statementContext , creationMetadata , null ) ;
833
+
834
+ //Assert
835
+ statement . Should ( ) . Be ( $@ "CREATE OR REPLACE TABLE { nameof ( OuterPoco2 ) } s (
836
+ { nameof ( OuterPoco2 . InnerPoco ) } STRUCT<Value INT, ValueNullable VARCHAR>,
837
+ { nameof ( OuterPoco2 . Id ) } INT PRIMARY KEY,
838
+ { nameof ( OuterPoco2 . Description ) } VARCHAR
839
+ ) WITH ( KAFKA_TOPIC='{ nameof ( Poco ) } ', VALUE_FORMAT='Json', PARTITIONS='1', REPLICAS='1' );" . ReplaceLineEndings ( ) ) ;
840
+ }
841
+
799
842
[ Test ]
800
843
public void ModelBuilder_IgnoreStructProperty ( )
801
844
{
802
845
//Arrange
803
- modelBuilder . Entity < PocoWithNullable > ( )
846
+ modelBuilder . Entity < Poco2 > ( )
804
847
. HasKey ( x => x . Id ) ;
805
- modelBuilder . Entity < PocoWithNullable > ( )
848
+ modelBuilder . Entity < Poco2 > ( )
806
849
. Property ( c => c . InnerPoco ) . AsStruct ( ) ;
807
- modelBuilder . Entity < PocoWithNullable > ( )
850
+ modelBuilder . Entity < Poco2 > ( )
808
851
. Property ( c => c . InnerPoco . InnerPoco2 ) . Ignore ( ) ;
809
- modelBuilder . Entity < PocoWithNullable > ( )
852
+ modelBuilder . Entity < Poco2 > ( )
810
853
. Property ( c => c . InnerPoco . Value ) ;
811
854
812
855
var statementContext = new StatementContext
@@ -818,11 +861,11 @@ public void ModelBuilder_IgnoreStructProperty()
818
861
creationMetadata . KafkaTopic = nameof ( Poco ) ;
819
862
820
863
//Act
821
- string statement = new CreateEntity ( modelBuilder ) . Print < PocoWithNullable > ( statementContext , creationMetadata , null ) ;
864
+ string statement = new CreateEntity ( modelBuilder ) . Print < Poco2 > ( statementContext , creationMetadata , null ) ;
822
865
823
866
//Assert
824
- statement . Should ( ) . Be ( $@ "CREATE OR REPLACE TABLE { nameof ( PocoWithNullable ) } s (
825
- { nameof ( PocoWithNullable . InnerPoco ) } STRUCT<Value VARCHAR>,
867
+ statement . Should ( ) . Be ( $@ "CREATE OR REPLACE TABLE { nameof ( Poco2 ) } s (
868
+ { nameof ( Poco2 . InnerPoco ) } STRUCT<Value VARCHAR>,
826
869
{ nameof ( Poco . Id ) } INT PRIMARY KEY,
827
870
{ nameof ( Poco . Description ) } VARCHAR
828
871
) WITH ( KAFKA_TOPIC='{ nameof ( Poco ) } ', VALUE_FORMAT='Json', PARTITIONS='1', REPLICAS='1' );" . ReplaceLineEndings ( ) ) ;
@@ -832,36 +875,36 @@ public void ModelBuilder_IgnoreStructProperty()
832
875
public void ModelBuilder_IgnoreStructPropertyOnOneEntityButNotOnAnother ( )
833
876
{
834
877
//Arrange
835
- modelBuilder . Entity < PocoWithNullable > ( )
878
+ modelBuilder . Entity < Poco2 > ( )
836
879
. HasKey ( x => x . Id ) ;
837
- modelBuilder . Entity < PocoWithNullable > ( )
880
+ modelBuilder . Entity < Poco2 > ( )
838
881
. Property ( c => c . InnerPoco ) . AsStruct ( ) ;
839
- modelBuilder . Entity < PocoWithNullable > ( )
882
+ modelBuilder . Entity < Poco2 > ( )
840
883
. Property ( c => c . InnerPoco . InnerPoco2 ) . Ignore ( ) ;
841
884
842
- modelBuilder . Entity < PocoWithNullable2 > ( )
885
+ modelBuilder . Entity < Poco3 > ( )
843
886
. HasKey ( x => x . Id ) ;
844
- modelBuilder . Entity < PocoWithNullable2 > ( )
887
+ modelBuilder . Entity < Poco3 > ( )
845
888
. Property ( c => c . InnerPoco ) . AsStruct ( ) ;
846
- modelBuilder . Entity < PocoWithNullable2 > ( )
889
+ modelBuilder . Entity < Poco3 > ( )
847
890
. Property ( c => c . InnerPoco . Value ) . Ignore ( ) ;
848
- modelBuilder . Entity < PocoWithNullable2 > ( )
891
+ modelBuilder . Entity < Poco3 > ( )
849
892
. Property ( c => c . InnerPoco . InnerPoco2 ) . AsStruct ( ) ;
850
893
851
- modelBuilder . Entity < PocoWithNullable3 > ( )
894
+ modelBuilder . Entity < Poco4 > ( )
852
895
. HasKey ( x => x . Id ) ;
853
- modelBuilder . Entity < PocoWithNullable3 > ( )
896
+ modelBuilder . Entity < Poco4 > ( )
854
897
. Property ( c => c . InnerPoco ) . AsStruct ( ) ;
855
- modelBuilder . Entity < PocoWithNullable3 > ( )
898
+ modelBuilder . Entity < Poco4 > ( )
856
899
. Property ( c => c . InnerPoco . InnerPoco2 ) . AsStruct ( ) ;
857
- modelBuilder . Entity < PocoWithNullable3 > ( )
900
+ modelBuilder . Entity < Poco4 > ( )
858
901
. Property ( c => c . InnerPoco . InnerPoco2 ! . FirstOrDefault ( ) ! . Value ) . Ignore ( ) ;
859
902
860
- modelBuilder . Entity < PocoWithNullable4 > ( )
903
+ modelBuilder . Entity < Poco5 > ( )
861
904
. HasKey ( x => x . Id ) ;
862
- modelBuilder . Entity < PocoWithNullable4 > ( )
905
+ modelBuilder . Entity < Poco5 > ( )
863
906
. Property ( c => c . InnerPoco ) . AsStruct ( ) ;
864
- modelBuilder . Entity < PocoWithNullable4 > ( )
907
+ modelBuilder . Entity < Poco5 > ( )
865
908
. Property ( c => c . InnerPoco . InnerPoco2 ) . AsStruct ( ) ;
866
909
867
910
var statementContext = new StatementContext
@@ -873,32 +916,32 @@ public void ModelBuilder_IgnoreStructPropertyOnOneEntityButNotOnAnother()
873
916
creationMetadata . KafkaTopic = nameof ( Poco ) ;
874
917
875
918
//Act
876
- var statement1 = new CreateEntity ( modelBuilder ) . Print < PocoWithNullable > ( statementContext , creationMetadata , null ) ;
877
- var statement2 = new CreateEntity ( modelBuilder ) . Print < PocoWithNullable2 > ( statementContext , creationMetadata , null ) ;
878
- var statement3 = new CreateEntity ( modelBuilder ) . Print < PocoWithNullable3 > ( statementContext , creationMetadata , null ) ;
879
- var statement4 = new CreateEntity ( modelBuilder ) . Print < PocoWithNullable4 > ( statementContext , creationMetadata , null ) ;
919
+ var statement1 = new CreateEntity ( modelBuilder ) . Print < Poco2 > ( statementContext , creationMetadata , null ) ;
920
+ var statement2 = new CreateEntity ( modelBuilder ) . Print < Poco3 > ( statementContext , creationMetadata , null ) ;
921
+ var statement3 = new CreateEntity ( modelBuilder ) . Print < Poco4 > ( statementContext , creationMetadata , null ) ;
922
+ var statement4 = new CreateEntity ( modelBuilder ) . Print < Poco5 > ( statementContext , creationMetadata , null ) ;
880
923
881
924
//Assert
882
- statement1 . Should ( ) . Be ( $@ "CREATE OR REPLACE TABLE { nameof ( PocoWithNullable ) } s (
883
- { nameof ( PocoWithNullable . InnerPoco ) } STRUCT<Value VARCHAR>,
925
+ statement1 . Should ( ) . Be ( $@ "CREATE OR REPLACE TABLE { nameof ( Poco2 ) } s (
926
+ { nameof ( Poco2 . InnerPoco ) } STRUCT<Value VARCHAR>,
884
927
{ nameof ( Poco . Id ) } INT PRIMARY KEY,
885
928
{ nameof ( Poco . Description ) } VARCHAR
886
929
) WITH ( KAFKA_TOPIC='{ nameof ( Poco ) } ', VALUE_FORMAT='Json', PARTITIONS='1', REPLICAS='1' );" . ReplaceLineEndings ( ) ) ;
887
930
888
- statement2 . Should ( ) . Be ( $@ "CREATE OR REPLACE TABLE { nameof ( PocoWithNullable2 ) } s (
889
- { nameof ( PocoWithNullable2 . InnerPoco ) } STRUCT<{ nameof ( PocoWithNullable2 . InnerPoco . InnerPoco2 ) } ARRAY<STRUCT<{ nameof ( InnerPoco2 . Value ) } INT>>>,
931
+ statement2 . Should ( ) . Be ( $@ "CREATE OR REPLACE TABLE { nameof ( Poco3 ) } s (
932
+ { nameof ( Poco3 . InnerPoco ) } STRUCT<{ nameof ( Poco3 . InnerPoco . InnerPoco2 ) } ARRAY<STRUCT<{ nameof ( InnerPoco2 . Value ) } INT>>>,
890
933
{ nameof ( Poco . Id ) } INT PRIMARY KEY,
891
934
{ nameof ( Poco . Description ) } VARCHAR
892
935
) WITH ( KAFKA_TOPIC='{ nameof ( Poco ) } ', VALUE_FORMAT='Json', PARTITIONS='1', REPLICAS='1' );" . ReplaceLineEndings ( ) ) ;
893
936
894
- statement3 . Should ( ) . Be ( $@ "CREATE OR REPLACE TABLE { nameof ( PocoWithNullable3 ) } s (
895
- { nameof ( PocoWithNullable3 . InnerPoco ) } STRUCT<Value VARCHAR>,
937
+ statement3 . Should ( ) . Be ( $@ "CREATE OR REPLACE TABLE { nameof ( Poco4 ) } s (
938
+ { nameof ( Poco4 . InnerPoco ) } STRUCT<Value VARCHAR>,
896
939
{ nameof ( Poco . Id ) } INT PRIMARY KEY,
897
940
{ nameof ( Poco . Description ) } VARCHAR
898
941
) WITH ( KAFKA_TOPIC='{ nameof ( Poco ) } ', VALUE_FORMAT='Json', PARTITIONS='1', REPLICAS='1' );" . ReplaceLineEndings ( ) ) ;
899
942
900
- statement4 . Should ( ) . Be ( $@ "CREATE OR REPLACE TABLE { nameof ( PocoWithNullable4 ) } s (
901
- { nameof ( PocoWithNullable4 . InnerPoco ) } STRUCT<{ nameof ( PocoWithNullable4 . InnerPoco . Value ) } VARCHAR, { nameof ( PocoWithNullable4 . InnerPoco . InnerPoco2 ) } ARRAY<STRUCT<{ nameof ( InnerPoco2 . Value ) } INT>>>,
943
+ statement4 . Should ( ) . Be ( $@ "CREATE OR REPLACE TABLE { nameof ( Poco5 ) } s (
944
+ { nameof ( Poco5 . InnerPoco ) } STRUCT<{ nameof ( Poco5 . InnerPoco . Value ) } VARCHAR, { nameof ( Poco5 . InnerPoco . InnerPoco2 ) } ARRAY<STRUCT<{ nameof ( InnerPoco2 . Value ) } INT>>>,
902
945
{ nameof ( Poco . Id ) } INT PRIMARY KEY,
903
946
{ nameof ( Poco . Description ) } VARCHAR
904
947
) WITH ( KAFKA_TOPIC='{ nameof ( Poco ) } ', VALUE_FORMAT='Json', PARTITIONS='1', REPLICAS='1' );" . ReplaceLineEndings ( ) ) ;
@@ -960,12 +1003,12 @@ public void ModelBuilder_IgnoreStructWithAllIgnoredFieldsProperty()
960
1003
// STRUCT<> is an invalid ksql statement
961
1004
962
1005
//Arrange
963
- modelBuilder . Entity < PocoWithNullable > ( )
1006
+ modelBuilder . Entity < Poco2 > ( )
964
1007
. HasKey ( x => x . Id )
965
1008
. Property ( c => c . InnerPoco ) . AsStruct ( ) ;
966
- modelBuilder . Entity < PocoWithNullable > ( )
1009
+ modelBuilder . Entity < Poco2 > ( )
967
1010
. Property ( c => c . InnerPoco . InnerPoco2 ) . Ignore ( ) ;
968
- modelBuilder . Entity < PocoWithNullable > ( )
1011
+ modelBuilder . Entity < Poco2 > ( )
969
1012
. Property ( c => c . InnerPoco . Value ) . Ignore ( ) ;
970
1013
971
1014
var statementContext = new StatementContext
@@ -977,10 +1020,10 @@ public void ModelBuilder_IgnoreStructWithAllIgnoredFieldsProperty()
977
1020
creationMetadata . KafkaTopic = nameof ( Poco ) ;
978
1021
979
1022
//Act
980
- string statement = new CreateEntity ( modelBuilder ) . Print < PocoWithNullable > ( statementContext , creationMetadata , null ) ;
1023
+ string statement = new CreateEntity ( modelBuilder ) . Print < Poco2 > ( statementContext , creationMetadata , null ) ;
981
1024
982
1025
//Assert
983
- statement . Should ( ) . Be ( $@ "CREATE OR REPLACE TABLE { nameof ( PocoWithNullable ) } s (
1026
+ statement . Should ( ) . Be ( $@ "CREATE OR REPLACE TABLE { nameof ( Poco2 ) } s (
984
1027
{ nameof ( Poco . Id ) } INT PRIMARY KEY,
985
1028
{ nameof ( Poco . Description ) } VARCHAR
986
1029
) WITH ( KAFKA_TOPIC='{ nameof ( Poco ) } ', VALUE_FORMAT='Json', PARTITIONS='1', REPLICAS='1' );" . ReplaceLineEndings ( ) ) ;
@@ -1000,12 +1043,12 @@ public void ModelBuilder_SubPropertiesOfAnIgnoredMemberAreSkipped()
1000
1043
// STRUCT<> is an invalid ksql statement
1001
1044
1002
1045
//Arrange
1003
- modelBuilder . Entity < PocoWithNullable > ( )
1046
+ modelBuilder . Entity < Poco2 > ( )
1004
1047
. HasKey ( x => x . Id )
1005
1048
. Property ( c => c . InnerPoco ) . Ignore ( ) ;
1006
- modelBuilder . Entity < PocoWithNullable > ( )
1049
+ modelBuilder . Entity < Poco2 > ( )
1007
1050
. Property ( c => c . InnerPoco . InnerPoco2 ) ;
1008
- modelBuilder . Entity < PocoWithNullable > ( )
1051
+ modelBuilder . Entity < Poco2 > ( )
1009
1052
. Property ( c => c . InnerPoco . Value ) ;
1010
1053
1011
1054
var statementContext = new StatementContext
@@ -1017,10 +1060,10 @@ public void ModelBuilder_SubPropertiesOfAnIgnoredMemberAreSkipped()
1017
1060
creationMetadata . KafkaTopic = nameof ( Poco ) ;
1018
1061
1019
1062
//Act
1020
- string statement = new CreateEntity ( modelBuilder ) . Print < PocoWithNullable > ( statementContext , creationMetadata , null ) ;
1063
+ string statement = new CreateEntity ( modelBuilder ) . Print < Poco2 > ( statementContext , creationMetadata , null ) ;
1021
1064
1022
1065
//Assert
1023
- statement . Should ( ) . Be ( $@ "CREATE OR REPLACE TABLE { nameof ( PocoWithNullable ) } s (
1066
+ statement . Should ( ) . Be ( $@ "CREATE OR REPLACE TABLE { nameof ( Poco2 ) } s (
1024
1067
{ nameof ( Poco . Id ) } INT PRIMARY KEY,
1025
1068
{ nameof ( Poco . Description ) } VARCHAR
1026
1069
) WITH ( KAFKA_TOPIC='{ nameof ( Poco ) } ', VALUE_FORMAT='Json', PARTITIONS='1', REPLICAS='1' );" . ReplaceLineEndings ( ) ) ;
0 commit comments