Change default postgreSQLEnumTypeName to include full type path #83
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR changes the default
postgreSQLEnumTypeName
by adding the entire type's path to the name.Example:
Consider the following case:
The two classes,
Foo
andBar
, each have a nested enum calledKind
, each aPostgreSQLEnum
.Currently the default
postgreSQLEnumTypeName
for both of these nested enums is the same:"KIND"
. Meaning that the resulting Postgres ENUM type for the first would be overridden by the second with no indication to the user that this happened.This PR would resolve that nuance by changing the default
postgreSQLEnumTypeName
to return unique names:"FOO_KIND"
and"BAR_KIND"
.Motivation:
This change is related to an issue discussed here. The motivating factor being, that in Swift, the types
Foo.Kind
andBar.Kind
are unique and distinguishable by the type system. It should then be reasonable to expect the defaultpostgreSQLEnumTypeName
s to be unique and the resulting Postgres ENUM types to be unique and distinguishable whereas currently, the first ENUM type created will be overridden by the second. This is counter-intuitive behavior, because it should be expected that two unique Swift enums will result in two unique Postgres ENUMs. In order to fully resolve the linked issue, and do so by default, this is a necessary change and will have a companion PR atFluent
to update the defaultmigrationName
(vapor/fluent#544).Impact:
This could potentially have an impact on existing codebases by changing
postgreSQLEnumTypeName
s that are already in place.