@@ -1127,12 +1127,12 @@ mod tests {
11271127
11281128 #[ derive( DeriveIntoActiveModel ) ]
11291129 #[ sea_orm( active_model = "fruit::ActiveModel" ) ]
1130- struct FruitName {
1130+ struct RequiredFruitName {
11311131 name : String ,
11321132 }
11331133
11341134 assert_eq ! (
1135- FruitName {
1135+ RequiredFruitName {
11361136 name: "Apple Pie" . to_owned( ) ,
11371137 }
11381138 . into_active_model( ) ,
@@ -1143,14 +1143,80 @@ mod tests {
11431143 }
11441144 ) ;
11451145
1146+ #[ derive( DeriveIntoActiveModel ) ]
1147+ #[ sea_orm( active_model = "fruit::ActiveModel" ) ]
1148+ struct OptionalFruitName {
1149+ name : Option < String > ,
1150+ }
1151+
1152+ assert_eq ! (
1153+ OptionalFruitName {
1154+ name: Some ( "Apple Pie" . to_owned( ) ) ,
1155+ }
1156+ . into_active_model( ) ,
1157+ fruit:: ActiveModel {
1158+ id: NotSet ,
1159+ name: Set ( "Apple Pie" . to_owned( ) ) ,
1160+ cake_id: NotSet ,
1161+ }
1162+ ) ;
1163+
1164+ assert_eq ! (
1165+ OptionalFruitName { name: None } . into_active_model( ) ,
1166+ fruit:: ActiveModel {
1167+ id: NotSet ,
1168+ name: NotSet ,
1169+ cake_id: NotSet ,
1170+ }
1171+ ) ;
1172+
1173+ #[ derive( DeriveIntoActiveModel ) ]
1174+ #[ sea_orm( active_model = "<fruit::Entity as EntityTrait>::ActiveModel" ) ]
1175+ struct RequiredAndNotNullFruitCake {
1176+ cake_id : i32 ,
1177+ }
1178+
1179+ assert_eq ! (
1180+ RequiredAndNotNullFruitCake { cake_id: 1 } . into_active_model( ) ,
1181+ fruit:: ActiveModel {
1182+ id: NotSet ,
1183+ name: NotSet ,
1184+ cake_id: Set ( Some ( 1 ) ) ,
1185+ }
1186+ ) ;
1187+
1188+ #[ derive( DeriveIntoActiveModel ) ]
1189+ #[ sea_orm( active_model = "<fruit::Entity as EntityTrait>::ActiveModel" ) ]
1190+ struct OptionalAndNotNullFruitCake {
1191+ cake_id : Option < i32 > ,
1192+ }
1193+
1194+ assert_eq ! (
1195+ OptionalAndNotNullFruitCake { cake_id: Some ( 1 ) } . into_active_model( ) ,
1196+ fruit:: ActiveModel {
1197+ id: NotSet ,
1198+ name: NotSet ,
1199+ cake_id: Set ( Some ( 1 ) ) ,
1200+ }
1201+ ) ;
1202+
1203+ assert_eq ! (
1204+ OptionalAndNotNullFruitCake { cake_id: None } . into_active_model( ) ,
1205+ fruit:: ActiveModel {
1206+ id: NotSet ,
1207+ name: NotSet ,
1208+ cake_id: NotSet ,
1209+ }
1210+ ) ;
1211+
11461212 #[ derive( DeriveIntoActiveModel ) ]
11471213 #[ sea_orm( active_model = "<fruit::Entity as EntityTrait>::ActiveModel" ) ]
1148- struct FruitCake {
1214+ struct OptionalAndNullableFruitCake {
11491215 cake_id : Option < Option < i32 > > ,
11501216 }
11511217
11521218 assert_eq ! (
1153- FruitCake {
1219+ OptionalAndNullableFruitCake {
11541220 cake_id: Some ( Some ( 1 ) ) ,
11551221 }
11561222 . into_active_model( ) ,
@@ -1162,7 +1228,7 @@ mod tests {
11621228 ) ;
11631229
11641230 assert_eq ! (
1165- FruitCake {
1231+ OptionalAndNullableFruitCake {
11661232 cake_id: Some ( None ) ,
11671233 }
11681234 . into_active_model( ) ,
@@ -1174,7 +1240,7 @@ mod tests {
11741240 ) ;
11751241
11761242 assert_eq ! (
1177- FruitCake { cake_id: None } . into_active_model( ) ,
1243+ OptionalAndNullableFruitCake { cake_id: None } . into_active_model( ) ,
11781244 fruit:: ActiveModel {
11791245 id: NotSet ,
11801246 name: NotSet ,
0 commit comments