Refactor macro attribute parsing: migrate from bae to darling and remove string/Ident round-trips - #3169
Open
TheShiveshNetwork wants to merge 7 commits into
Conversation
Huliiiiii
reviewed
Aug 12, 2026
Huliiiiii
reviewed
Aug 12, 2026
Huliiiiii
reviewed
Aug 12, 2026
Huliiiiii
reviewed
Aug 12, 2026
|
|
||
| /// Attributes for compound model fields | ||
| #[derive(Default, FromAttributes)] | ||
| #[derive(Default, FromMeta)] |
Member
There was a problem hiding this comment.
This doesn't solve the issue. You should replace the current manually parsed compatibility layer with darling.
Huliiiiii
reviewed
Aug 12, 2026
Author
|
@Huliiiiii this pr should be ready for review. moreover, i've also opened the pr for migration of syn 2 to syn 3 #3171 we can complete that first and then, i'll migrate darling to latest once that is merged. |
Member
Please, I don't want to see this kind of LLM slop. You also haven't understood what we're trying to fix. Please put more thought into the code. If you're going to rely on LLM, it'd be much easier for me to just do it myself. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
bae->darlingmigration is part of this branch:bae(sea-bae) is fully removed and all five attribute structs (derive_attr,relation_attr,compound_attr,value_type_attr,related_attr) now usedarling::FromMeta.darlingis pinned to0.23(latest release still onsyn 2.0;0.24would require a separatesyn2->3 migration). The originaltry_from_attributes/from_attributessignatures are preserved so call sites are unchanged.parse_nested_meta(a few derives here already do that, e.g.column.rs/derive_iden.rs, so it's not like it'd be a foreign pattern). Ended up going with darling becausecompound_attrhas 14 fields and actual co-occurrence rules between them (from+toneed each other,has_one/belongs_toare mutually exclusive, etc.), and writing that validation by hand for all 5 structs felt like we'd just be badly reinventing whatFromMetaalready does. Also figured darling being a known quantity in the ecosystem is nicer for anyone picking this crate up later than a parser only sea-orm uses.3.0.3, yet to create the prNew Features
Bug Fixes
Breaking Changes
#[sea_orm(...)]) is untouched, this is purely how the macros parse it internally.Changes
baetodarling. Removed thebae/sea-baedependency; the five attribute structs insea-orm-macros/src/derives/attributes.rsnow derivedarling::FromMeta, with validation deferred so unknown attributes still warn rather than error.Ident::new(&format!(..))withformat_ident!for literal and transformed idents across the derive macros (model_ex,active_model_ex,entity_model,typed_column,value_type_match,related_entity,entity_loader,partial_model,into_active_model,raw_sql).syn::parse_quote!instead ofsyn::parse_stron a formatted string (e.g. the#[sea_orm(compact)]relatedActiveModelpath inpartial_model).Idents directly via*id == "some_str"instead of stringifying with.to_string()first, mainly inutil.rs'sCompoundType::matches_type/CompoundType::from_type(worst offender, 5 stringify-then-match sites in one function), plus a few smaller ones inactive_enum.rs,column.rs, andderive_iden.rs.