{"record":{"id":"890ba752dd41a83b","repo":"diesel-rs/diesel","slug":"expected-a-single-table-name-attribute-note-remov","errorCode":null,"errorMessage":"expected a single table name attribute\nnote: remove this attribute","messagePattern":"expected a single table name attribute\nnote: remove this attribute","errorType":"exception","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"diesel_derives/src/model.rs","lineNumber":92,"sourceCode":"        let mut sql_types = vec![];\n        let mut aggregate = false;\n        let mut not_sized = false;\n        let mut enum_type = false;\n        let mut foreign_derive = false;\n        let mut mysql_type = None;\n        let mut mariadb_type = None;\n        let mut sqlite_type = None;\n        let mut postgres_type = None;\n        let mut check_for_backend = None;\n        let mut base_query = None;\n        let mut base_query_type = None;\n\n        for attr in parse_attributes(attrs)? {\n            match attr.item {\n                StructAttr::SqlType(_, value) => sql_types.push(Type::Path(value)),\n                StructAttr::TableName(ident, value) => {\n                    if !allow_multiple_table && !table_names.is_empty() {\n                        return Err(syn::Error::new(\n                            ident.span(),\n                            \"expected a single table name attribute\\n\\\n                             note: remove this attribute\",\n                        ));\n                    }\n                    table_names.push(value)\n                }\n                StructAttr::PrimaryKey(_, keys) => {\n                    primary_key_names = keys.into_iter().collect();\n                }\n                StructAttr::TreatNoneAsDefaultValue(_, val) => {\n                    treat_none_as_default_value = Some(val)\n                }\n                StructAttr::TreatNoneAsNull(_, val) => treat_none_as_null = Some(val),\n                StructAttr::BelongsTo(_, val) => belongs_to.push(val),\n                StructAttr::Aggregate(_) => aggregate = true,\n                StructAttr::NotSized(_) => not_sized = true,\n                StructAttr::ForeignDerive(_) => foreign_derive = true,","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/diesel-rs/diesel/blob/6fa6ed01b24b24248ab2a611698d0a7c6a2e9120/diesel_derives/src/model.rs#L74-L110","documentation":"For single-table derives, the item may carry only one `#[diesel(table_name = ...)]` attribute. When `allow_multiple_table` is false and a second `table_name` attribute is parsed, model.rs raises this error, telling you to delete the extra attribute.","triggerScenarios":"Two `#[diesel(table_name = ...)]` attributes on one struct derived with a single-table derive (Queryable/Insertable/Identifiable etc.).","commonSituations":"Merging code from two structs without deduplicating attributes; switching to `#[diesel(multi_table_name ...)]` semantics by just adding another table_name; copy-paste leftovers.","solutions":["Delete the duplicate `table_name` attribute, keeping exactly one.","If you really need several tables, check whether your diesel version offers a multi-table/join mechanism instead of stacking attributes.","Verify no attribute is duplicated across `#[diesel(...)]` groups on the same item."],"exampleFix":"// before\n#[derive(Queryable)]\n#[diesel(table_name = users)]\n#[diesel(table_name = posts)]\nstruct Row { id: i32 }\n\n// after\n#[derive(Queryable)]\n#[diesel(table_name = users)]\nstruct Row { id: i32 }","handlingStrategy":"validation","validationCode":"// Exactly one table_name attribute per single-table derive:\n// #[diesel(table_name = users)]  // keep this\n// #[diesel(table_name = posts)]  // delete this","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Grep structs for duplicate `table_name` attributes after merging code.","Use the dedicated multi-table mechanism if you need joins, not stacked attributes.","Keep all diesel attributes consolidated in one `#[diesel(...)]` group to spot duplicates."],"tags":["proc-macro","derive","duplicate-attribute","compile-time"],"backgroundTag":"mutually-exclusive-options","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"}