File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -79,6 +79,26 @@ class Atom
7979 # ```
8080 {% pk = type [" reference_type" ].constant(" MODEL_PRIMARY_KEY" ) % }
8181 {% pk_type = type [" reference_type" ].constant(" MODEL_PRIMARY_KEY_TYPE" ) % }
82+ {%
83+ type = type
84+ unless pk && pk_type
85+ raise <<-TEXT
86+ Primary key of #{ type [" reference_type" ]} is not defined at this moment of compilation.
87+
88+ Please try requiring it before using as a reference.
89+
90+ \e [32m+\e [39m️ Valid code:
91+
92+ \e [32mrequire "./#{ type [" reference_type" ].stringify.underscore.id} "\e [39m # Actual path may be different
93+
94+ class #{ @type }
95+ schema #{ MODEL_TABLE } do
96+ type #{ type [" name" ]} : #{ type [" type" ]}
97+ end
98+ end
99+ TEXT
100+ end
101+ % }
82102
83103 {% if type [" enumerable" ] % }
84104 @{{type [" name" ]}} = rs.read({{type [" enumerable" ]}}({{pk_type}}) | Nil ).try & .map do |pk |
You can’t perform that action at this time.
0 commit comments