sea-orm icon indicating copy to clipboard operation
sea-orm copied to clipboard

Proc macro parsing with darling and test

Open Diwakar-Gupta opened this issue 3 years ago • 7 comments

Still Working need feedback

PR Info

Fixes Problem discussed at https://github.com/SeaQL/sea-orm/issues/394#issuecomment-1396947927.

Related PR

https://github.com/SeaQL/sea-orm/pull/1560

Tasks

  • [x] Replace manually parsing with darling
  • [x] Write test for parser

File Changed

  1. sea-orm-macros/Cargo.toml added darling dependency
  2. sea-orm-macros/src/derives/model.rs modified parser and added test

Diwakar-Gupta avatar Jan 21 '23 00:01 Diwakar-Gupta

Thanks for the feedback.

I will look after replacing DeriveModel with DeriveModelDarling. This will lead to changes in impl_from_query_result impl_model_trait as they both depend on struct DeriveModel.

Diwakar-Gupta avatar Jan 26 '23 06:01 Diwakar-Gupta

Wow, interesting. I have never used darling. Seems like it can make the code much cleaner!

tyt2y3 avatar Jan 26 '23 07:01 tyt2y3

Yep, wanna get rid of the parsing mess ASAP loll

billy1624 avatar Jan 26 '23 08:01 billy1624

Hey @Diwakar-Gupta, I think you leave a comment here yesterday night but it's now gone. Anything I could help?

billy1624 avatar Jan 27 '23 10:01 billy1624

@billy1624 The comment was a report of changes done; Then I did some more changes and it became irrelevant. Here is the latest summary.

All this are also commented in code.

  1. Previously DeriveModel had processed data, removing it has introduced some extra processing in impl_from_query_result and impl_model_trait functions. But it is manageable at least in my opinion.

  2. struct is only supported this is ensured by darling now, and default darling error message is shown to user for now. cant give custom error message unless darling makes some necessary module public.

Diwakar-Gupta avatar Jan 27 '23 10:01 Diwakar-Gupta

Thanks @billy1624 I will study the reference you have given.

Diwakar-Gupta avatar Mar 21 '23 17:03 Diwakar-Gupta

hey @billy1624 i have used your pr https://github.com/SeaQL/sea-orm/pull/1560 and fixed the merge conflict.

Diwakar-Gupta avatar Apr 16 '23 16:04 Diwakar-Gupta