-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't parse all attributes as Meta
#774
Comments
diff --git a/sqlx-macros/src/derives/attributes.rs b/sqlx-macros/src/derives/attributes.rs
index 3feea50b..4d2dadbb 100644
--- a/sqlx-macros/src/derives/attributes.rs
+++ b/sqlx-macros/src/derives/attributes.rs
@@ -123,13 +123,13 @@ pub fn parse_child_attributes(input: &[Attribute]) -> syn::Result<SqlxChildAttri
let mut rename = None;
let mut default = false;
- for attr in input {
+ for attr in input.iter().filter(|a| a.path.is_ident("sqlx")) {
let meta = attr
.parse_meta()
.map_err(|e| syn::Error::new_spanned(attr, e))?;
match meta {
- Meta::List(list) if list.path.is_ident("sqlx") => {
+ Meta::List(list) => {
for value in list.nested.iter() {
match value {
NestedMeta::Meta(meta) => match meta { I think something like that should fix that problem, right? I can not test at the moment since I have problem build my project with a local version of sqlx. Complains about that no runtime is enabled (but it is). |
Yeah, that should do the trick! |
I wonder what the |
I removed the second check when you look at the patch. Ok, I will create a PR in a minute :) |
Oh, right! 😅 To make it easier to read diffs in GitHub comments you can start the codeblock with |
Currently, sqlx parses every field attribute as
Meta
.This breaks for every struct which has non-meta attributes with custom syntax. In ormx, for example, I have attributes which may have a path as value, for example:
#[ormx(table = crate::models::User)]
.When parsing attributes, I suggest we first check if the first token is
sqlx
, then continue parsing asMeta
.The text was updated successfully, but these errors were encountered: