enums not usable in multiple models or fields within the same model
goldcaddy77 opened this issue · 2 comments
From @dzhelezov on Gitter:
Spotted the following issue with
@EnumField
. When I have two separated entities each having a field of the same enum type, the generated file generated/classes.ts imports the class twice. This causes an error, and I think that's b/c the enumfield decorator reexports whatever enum type is imported
The solution is to add an Enum decorator that registers the enum separate from the EnumField (or just make sure the EnumField decorator registers a unique copy per enum)
In order for this to not be a breaking change, we can’t require a new decorator, so we need to update the current flow.
The change needed is to ensure we’re only adding the import statement for each of these enums once here:
warthog/src/schema/TypeORMConverter.ts
Line 51 in a02a237
We just need to create a Set of the already imported filename
s and don’t import if the file already exists.
Fixed in #403