Skip to content

Conversation

@siketyan
Copy link
Contributor

PR Info

  • Closes N/A
  • Dependencies:
    • N/A
  • Dependents:
    • N/A

New Features

N/A

Bug Fixes

N/A

Breaking Changes

N/A

Changes

  • sea-orm-macros now uses syn v2.

[dependencies]
bae = { version = "0.1", default-features = false }
syn = { version = "1", default-features = false, features = ["parsing", "proc-macro", "derive", "printing"] }
bae2 = { version = "1", default-features = false }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since bae crate is no longer maintained and it is required that bae is upgrade to syn v2 too, so I made a fork of bae and published to crates.io.

Copy link
Member

@billy1624 billy1624 Mar 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any alternative for bae?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we adopt darling? Just like #1412

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@billy1624
I think we can adopt darling after TedDriggs/darling#226 got merged. Also it is not so difficult to parse attributes without bae or darling, thanks to parse_nested_meta API. In fact, major of sea_orm attributes are parsed manually without using bae.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking we use Darling since it has nicer errors when you get a name wrong

continue;
}
} else {
if !attr.path().is_ident("sea_orm") {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use this shorthand syntax.

Comment on lines 48 to 49
if let Expr::Lit(exprlit) = &nv.value {
if let Lit::Str(litstr) = &exprlit.lit {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value of MetaNameValue is now Expr, so we need to check whether the value is Lit or not first.

@siketyan siketyan marked this pull request as draft March 21, 2023 09:23
@siketyan siketyan marked this pull request as ready for review March 21, 2023 10:30
@siketyan siketyan requested a review from billy1624 March 21, 2023 10:30
@billy1624
Copy link
Member

Hey @siketyan, thanks for the hard work!! Perhaps we can rewrite all macros after TedDriggs/darling#226 merged and released?

I will convert this into a draft PR for now.

@billy1624 billy1624 marked this pull request as draft March 22, 2023 06:42
@siketyan
Copy link
Contributor Author

siketyan commented Mar 23, 2023

@billy1624 Yes, maybe. I saw your PoC. But I do not know we can or can not rewrite default_value attribute on ColumnTrait using darling.
default_value accepts all literals, including string and integer, so it is needed that darling can handle an attribute by syn::Lit or something.

Btw I can work on this after the syn's PR got merged.

@AlbertMarashi
Copy link
Contributor

+1 on using darling for attributes. they seem to have more helpful error messages for mistyped attribute names

@siketyan
Copy link
Contributor Author

I totally agree to use darling instead. TedDriggs/darling#226 has been merged and we're ready to migrate.

@siketyan siketyan closed this May 24, 2023
@siketyan siketyan deleted the feat/syn-2 branch May 24, 2023 02:35
This was referenced Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants