File tree Expand file tree Collapse file tree 1 file changed +20
-16
lines changed
Expand file tree Collapse file tree 1 file changed +20
-16
lines changed Original file line number Diff line number Diff line change @@ -362,22 +362,26 @@ defmodule AshPostgres.ResourceGenerator do
362362 Enum . find ( table_spec . relationships , fn relationship ->
363363 relationship . type == :belongs_to and
364364 relationship . constraint_name == foreign_key . constraint_name
365- end ) . name
366-
367- options =
368- ""
369- |> add_on ( :update , foreign_key . on_update )
370- |> add_on ( :delete , foreign_key . on_delete )
371- |> add_match_with ( foreign_key . match_with )
372- |> add_match_type ( foreign_key . match_type )
373-
374- [
375- """
376- reference :#{ relationship } do
377- #{ options }
378- end
379- """
380- ]
365+ end )
366+
367+ if relationship do
368+ relationship = relationship . name
369+
370+ options =
371+ ""
372+ |> add_on ( :update , foreign_key . on_update )
373+ |> add_on ( :delete , foreign_key . on_delete )
374+ |> add_match_with ( foreign_key . match_with )
375+ |> add_match_type ( foreign_key . match_type )
376+
377+ [
378+ """
379+ reference :#{ relationship } do
380+ #{ options }
381+ end
382+ """
383+ ]
384+ end
381385 end
382386 |> Enum . join ( "\n " )
383387 |> String . trim ( )
You can’t perform that action at this time.
0 commit comments