You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
denwong47
changed the title
string_value of DeriveActiveEnum errors on underscores, spaces and Non-Unicode SA#31 chars
string_value of DeriveActiveEnum errors on underscores, spaces and Non-Unicode UAX#31 chars
Jan 8, 2023
Description
This Issue accompanies a PR that fixes it. PR Link to follow in comments below.
When using
DeriveActiveEnum
,struct ActiveEnum
will try to reformat thestring_value
into an identifier for anEnum
. Its does this by:This causes a few problems:
string_value
is an empty string, or"$"
or multiples of themcamel_case
will remove: e.g."_"
or" "
string_value
s that differ only by the above characters will become conflicting identifiers:string_value
of"fooBar"
and"foo_bar"
in the sameenum
will result conflicting identifiers ofFooBar
.string_value
leads with a digit, camel_case will NOT be applied, hencestring_value = "0spaced word"
will cause an error.Steps to Reproduce
Scenario 1 - non-empty
string_value
results in empty identifierScenario 2 - distinct
string_value
s result in conflictScenario 3 -
string_value
with leading numeric and includes spacesExpected Behavior
Compiles successfully with an
Member1
matchingstring_value
mapped.Actual Behavior
Scenario 1
proc_macro panicked:
message: "" is not a valid identifier
Scenario 2
error[E0428]:
the name AB is defined multiple times
Scenario 3
proc_macro panicked:
message: "_0 123" is not a valid identifier
Reproduces How Often
Always reproducible.
Versions
sea-orm-macros 0.10.3
Additional Information
The text was updated successfully, but these errors were encountered: