{"record":{"id":"2c19cdf0e5ad4dc9","repo":"diesel-rs/diesel","slug":"all-fields-of-tuple-structs-must-be-annotated-with","errorCode":null,"errorMessage":"all fields of tuple structs must be annotated with `#[diesel(column_name)]`","messagePattern":"all fields of tuple structs must be annotated with `#\\[diesel\\(column_name\\)\\]`","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"diesel_derives/src/field.rs","lineNumber":163,"sourceCode":"            treat_none_as_null,\n            serialize_as,\n            deserialize_as,\n            select_expression,\n            select_expression_type,\n            embed,\n            skip_insertion,\n            skip_update,\n        })\n    }\n\n    pub fn column_name(&self) -> Result<SqlIdentifier> {\n        let identifier = self.column_name.as_ref().map(|a| a.item.clone());\n        if let Some(identifier) = identifier {\n            Ok(identifier)\n        } else {\n            match self.name {\n                FieldName::Named(ref x) => Ok(x.into()),\n                FieldName::Unnamed(ref x) => Err(syn::Error::new(\n                    x.span(),\n                    \"all fields of tuple structs must be annotated with `#[diesel(column_name)]`\",\n                )),\n            }\n        }\n    }\n\n    pub fn ty_for_deserialize(&self) -> &Type {\n        if let Some(AttributeSpanWrapper { item: value, .. }) = &self.deserialize_as {\n            value\n        } else {\n            &self.ty\n        }\n    }\n\n    pub(crate) fn embed(&self) -> bool {\n        self.embed.as_ref().map(|a| a.item).unwrap_or(false)\n    }","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/diesel-rs/diesel/blob/6fa6ed01b24b24248ab2a611698d0a7c6a2e9120/diesel_derives/src/field.rs#L145-L181","documentation":"When deriving a diesel struct mapping (e.g. `Queryable`, `Insertable`) on a tuple struct, every field must carry an explicit `#[diesel(column_name = ...)]`, since tuple fields have no usable column-name source. `FieldName::Unnamed` without a column_name attribute reaches `column_name()` and raises this error at field.rs:163.","triggerScenarios":"Deriving diesel traits on a tuple struct where at least one positional field lacks `#[diesel(column_name = ...)]`.","commonSituations":"Newtype wrappers around a single column where the author assumed the derive would infer the column; partially annotated tuple structs; converting a named struct to a tuple struct without moving the attributes.","solutions":["Annotate every field with `#[diesel(column_name = the_column)]`.","Prefer a named struct, which infers column names from field names automatically.","For a newtype over one column, verify the derive supports inference for your case or keep the explicit annotation."],"exampleFix":"// before\n#[derive(Queryable)]\npub struct UserRow(pub i32, pub String);\n\n// after\n#[derive(Queryable)]\npub struct UserRow(\n  #[diesel(column_name = id)] pub i32,\n  #[diesel(column_name = name)] pub String,\n);","handlingStrategy":"validation","validationCode":"// For tuple structs, every positional field needs a column_name:\n// struct Row(#[diesel(column_name = id)] i32, #[diesel(column_name = name)] String);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer named structs so column names are inferred from field names.","When using tuple structs, annotate every field with `#[diesel(column_name = ...)]`.","Re-check annotations after converting a named struct to a tuple struct."],"tags":["proc-macro","derive","column-name","tuple-struct","compile-time"],"backgroundTag":"missing-required-argument","analyzedSha":"6fa6ed01b24b24248ab2a611698d0a7c6a2e9120","analyzedAt":"2026-09-07T01:50:13.074Z","contentChangedAt":"2026-09-07T01:50:13.074Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}