reform
reform copied to clipboard
Make view/table generator optional
Sometimes we want to generate code only for Struct/Record, and not for View/Table. For example, see this reform-db model.
In a magic comment, table name -
(as in //reform:-
) should generate Struct/Record, but skip View/Table code.
I wanted to help with this task, so I checked the code and it appears that it's not that easy: interface Struct
has View() View
method (https://github.com/go-reform/reform/blob/e66d9634783b49cfa2f9a4105691e6b1ef7c35bc/base.go#L62), so the generation of the view cannot just be skipped without API changes.
As soon as NextRow
does not actually need .View()
the possible solution could be is to split Struct
interface into two: "pure struct" and "struct with a view", that embeds "pure struct" and adds .View()
and then change the signature of NextRow()
(naming is something that needs discussion).
What do you think?