Added escaping to ActiveEnum to allow for non-UAX#31 chars, as well as camel_case related conflicts.#1374
Conversation
|
Fixed CI errors. Apologies! |
|
|
||
| #[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Copy)] | ||
| #[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "pop_os_names_typos")] | ||
| pub enum PopOSTypos { |
It will be great if we can also include this example as a doc test! |
|
Thank you, I'll have a look at doc testing tomorrow! |
…eaQL#31 characters, as well as addressing issues with ' ' and '_' causing potential identifier conflicts.
14390cb to
30d385f
Compare
|
Changes post-review:
|
|
Hey @denwong47, I just fetch from latest master. Now, I'm going to add a few more test cases here and there before merging. Thanks for the efforts!! Great contribution! :) |
billy1624
left a comment
There was a problem hiding this comment.
Thanks again for the PR! More PRs are welcomed! See you around on GitHub :P
* Optional Field SeaQL/sea-orm#1513 * .gitignore SeaQL/sea-orm#1334 * migration table custom name SeaQL/sea-orm#1511 * OR condition relation SeaQL/sea-orm#1433 * DerivePartialModel SeaQL/sea-orm#1597 * space for migration file naming SeaQL/sea-orm#1570 * composite key up to 12 SeaQL/sea-orm#1508 * seaography integration SeaQL/sea-orm#1599 * QuerySelect SimpleExpr SeaQL/sea-orm#1702 * sqlErr SeaQL/sea-orm#1707 * migration check SeaQL/sea-orm#1519 * postgres array SeaQL/sea-orm#1565 * param intoString SeaQL/sea-orm#1439 * **skipped** re-export SeaQL/sea-orm#1661 * ping SeaQL/sea-orm#1627 * on empty do nothing SeaQL/sea-orm#1708 * on conflict do nothing SeaQL/sea-orm#1712 * **skipped** upgrade versions * active enum fail safe SeaQL/sea-orm#1374 * relation generation check SeaQL/sea-orm#1435 * entity generation bug SeaQL/sea-schema#105 * **skipped** bug fix that does not require edits * EnumIter change SeaQL/sea-orm#1535 * completed and fixed a previous todo SeaQL/sea-orm#1570 * amended wordings and structures * Edit * Remove temp file --------- Co-authored-by: Billy Chan <[email protected]>
🎉 Released In 0.12.1 🎉Thank you everyone for the contribution! |
PR Info
Bug Fixes
DeriveActiveEnumthrowing"" is not a valid identifierpanic ifstring_valueconsists only of non-UAX#31 compliant charactersthe name SomeName is defined multiple timesif two enum values havestring_valueofsomeNameandsome_namerespectively"_0 123" is not a valid identifierifstring_valuestarts with any digit followed by at least one space in the string.Details
This adds a function
camel_case_with_escaped_non_xidtoutil.rsofsea-orm-macros, which is a wrapper forcamel_caseto conduct further escaping specifically suitable for Rust Identifiers.It does so by:
_or whitespace, andXID_Startcharacter set for first character, andXID_Continuecharacter set for the rest of the stringu32, then replace original character with its{:X}hex representation: e.g. whitespace becomes0x20."__Empty".camel_case.numeric; if so, prepend anunderscore.For example,
will now produce the following Variant Enum:
See Also
Valid Rust Identifier talking about XID_Start and XID_Continue