File tree Expand file tree Collapse file tree 2 files changed +41
-5
lines changed
Expand file tree Collapse file tree 2 files changed +41
-5
lines changed Original file line number Diff line number Diff line change @@ -2153,7 +2153,7 @@ defmodule Spark.Dsl.Extension do
21532153
21542154 def __after_verify__ ( module ) do
21552155 dsl_patch_structs =
2156- for % Spark.Dsl.Patch.AddEntity { entity: entity } <- module . dsl_patches ( ) , do: entity . target
2156+ for patch <- module . dsl_patches ( ) , entity <- patch_entities ( patch ) , do: entity . target
21572157
21582158 section_structs =
21592159 for section <- module . sections ( ) , entity <- section_entities ( section ) , do: entity . target
@@ -2173,10 +2173,29 @@ defmodule Spark.Dsl.Extension do
21732173 :ok
21742174 end
21752175
2176+ defp patch_entities ( % Spark.Dsl.Patch.AddEntity { entity: entity } ) do
2177+ nested_entities ( entity )
2178+ end
2179+
21762180 defp section_entities ( % Spark.Dsl.Section {
21772181 entities: entities ,
21782182 sections: sections
21792183 } ) do
2180- entities ++ Enum . flat_map ( sections , & section_entities / 1 )
2184+ [
2185+ entities ,
2186+ Enum . flat_map ( sections , & section_entities / 1 )
2187+ ]
2188+ |> Enum . concat ( )
2189+ |> Enum . flat_map ( & nested_entities / 1 )
2190+ end
2191+
2192+ defp nested_entities ( % Spark.Dsl.Entity { entities: entities } = entity ) do
2193+ [
2194+ entity
2195+ | Enum . flat_map ( entities , fn
2196+ { _key , nested_entities } -> List . wrap ( nested_entities )
2197+ other -> List . wrap ( other )
2198+ end )
2199+ ]
21812200 end
21822201end
Original file line number Diff line number Diff line change @@ -917,7 +917,11 @@ defmodule Spark.DslTest do
917917 describe "missing spark metadata warnings" do
918918 test "warns when entity does not have __spark_metadata__ field" do
919919 # Create an entity struct without __spark_metadata__ field
920- defmodule WarningStruct do
920+ defmodule WarningStructOuter do
921+ defstruct [ :name ]
922+ end
923+
924+ defmodule WarningStructNested do
921925 defstruct [ :name ]
922926 end
923927
@@ -927,9 +931,21 @@ defmodule Spark.DslTest do
927931 @ entity_without_metadata % Spark.Dsl.Entity {
928932 name: :entity_without_metadata ,
929933 args: [ :name ] ,
930- target: WarningStruct ,
934+ target: WarningStructOuter ,
931935 schema: [
932936 name: [ type: :atom ]
937+ ] ,
938+ entities: [
939+ nested: [
940+ % Spark.Dsl.Entity {
941+ name: :entity_without_metadata ,
942+ args: [ :name ] ,
943+ target: WarningStructNested ,
944+ schema: [
945+ name: [ type: :atom ]
946+ ]
947+ }
948+ ]
933949 ]
934950 }
935951
@@ -943,7 +959,8 @@ defmodule Spark.DslTest do
943959 end )
944960
945961 assert warning_output =~ "Entity without __spark_metadata__ field"
946- assert warning_output =~ "WarningStruct"
962+ assert warning_output =~ "WarningStructOuter"
963+ assert warning_output =~ "WarningStructNested"
947964 assert warning_output =~ "__spark_metadata__: nil"
948965 end
949966 end
You can’t perform that action at this time.
0 commit comments