@@ -379,14 +379,15 @@ attribute_names_forms(ModuleName, Parameters) ->
379379has_one_forms (HasOne , ModuleName , Opts ) ->
380380 Type = proplists :get_value (module , Opts , HasOne ),
381381 ForeignKey = proplists :get_value (foreign_key , Opts , atom_to_list (ModuleName ) ++ " _id" ),
382+ Include = proplists :get_value (include , Opts , []),
382383 [erl_syntax :add_precomments ([erl_syntax :comment (
383384 [lists :concat ([" % @spec " , HasOne , " () -> " , Type , " | undefined" ]),
384385 lists :concat ([" % @doc Retrieves the `" , Type , " ' with `" , ForeignKey , " ' " ,
385386 " set to the `Id' of this `" , ModuleName , " '" ])])],
386387 erl_syntax :function (erl_syntax :atom (HasOne ),
387388 [erl_syntax :clause ([], none , [
388389 first_or_undefined_forms (
389- has_many_application_forms (Type , ForeignKey , 1 , id , false )
390+ has_many_application_forms (Type , ForeignKey , 1 , id , false , Include )
390391 )
391392 ])]))
392393 ].
@@ -398,6 +399,7 @@ has_many_forms(HasMany, ModuleName, Limit, Opts) ->
398399 IsDescending = proplists :get_value (descending , Opts , false ),
399400 Singular = inflector :singularize (atom_to_list (HasMany )),
400401 Type = proplists :get_value (module , Opts , Singular ),
402+ Include = proplists :get_value (include , Opts , []),
401403 ForeignKey = proplists :get_value (foreign_key , Opts , atom_to_list (ModuleName ) ++ " _id" ),
402404 [erl_syntax :add_precomments ([erl_syntax :comment (
403405 [
@@ -406,7 +408,7 @@ has_many_forms(HasMany, ModuleName, Limit, Opts) ->
406408 " set to the `Id' of this `" , ModuleName , " '" ])])],
407409 erl_syntax :function (erl_syntax :atom (HasMany ),
408410 [erl_syntax :clause ([], none , [
409- has_many_application_forms (Type , ForeignKey , Limit , Sort , IsDescending )
411+ has_many_application_forms (Type , ForeignKey , Limit , Sort , IsDescending , Include )
410412 ])])),
411413 erl_syntax :add_precomments ([erl_syntax :comment (
412414 [
@@ -416,7 +418,7 @@ has_many_forms(HasMany, ModuleName, Limit, Opts) ->
416418 erl_syntax :function (erl_syntax :atom (" first_" ++ Singular ),
417419 [erl_syntax :clause ([], none , [
418420 first_or_undefined_forms (
419- has_many_application_forms (Type , ForeignKey , 1 , Sort , IsDescending )
421+ has_many_application_forms (Type , ForeignKey , 1 , Sort , IsDescending , Include )
420422 )
421423 ])])),
422424 erl_syntax :add_precomments ([erl_syntax :comment (
@@ -427,7 +429,7 @@ has_many_forms(HasMany, ModuleName, Limit, Opts) ->
427429 erl_syntax :function (erl_syntax :atom (" last_" ++ Singular ),
428430 [erl_syntax :clause ([], none , [
429431 first_or_undefined_forms (
430- has_many_application_forms (Type , ForeignKey , 1 , Sort , not IsDescending )
432+ has_many_application_forms (Type , ForeignKey , 1 , Sort , not IsDescending , Include )
431433 )
432434 ])]))
433435 ].
@@ -438,7 +440,7 @@ first_or_undefined_forms(Forms) ->
438440 [erl_syntax :variable (? PREFIX ++ " Record" )]),
439441 erl_syntax :clause ([erl_syntax :underscore ()], none , [erl_syntax :atom (undefined )])]).
440442
441- has_many_application_forms (Type , ForeignKey , Limit , Sort , IsDescending ) ->
443+ has_many_application_forms (Type , ForeignKey , Limit , Sort , IsDescending , Include ) ->
442444 erl_syntax :application (
443445 erl_syntax :atom (? DATABASE_MODULE ),
444446 erl_syntax :atom (find ),
@@ -457,7 +459,10 @@ has_many_application_forms(Type, ForeignKey, Limit, Sort, IsDescending) ->
457459 erl_syntax :atom (Sort )]),
458460 erl_syntax :tuple ([
459461 erl_syntax :atom (descending ),
460- erl_syntax :atom (IsDescending )])
462+ erl_syntax :atom (IsDescending )]),
463+ erl_syntax :tuple ([
464+ erl_syntax :atom (include ),
465+ erl_syntax :list (lists :map (fun erl_syntax :atom /1 , Include ))])
461466 ])
462467 ]).
463468
0 commit comments