{"record":{"id":"b1cfc69b91510b61","repo":"SeaQL/sea-orm","slug":"cannot-apply-alias-for-column-with-asterisk","errorCode":null,"errorMessage":"cannot apply alias for Column with asterisk","messagePattern":"cannot apply alias for Column with asterisk","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/query/combine.rs","lineNumber":58,"sourceCode":"select_def!(SelectF, \"F_\");\n\nimpl<E> Select<E>\nwhere\n    E: EntityTrait,\n{\n    pub(crate) fn apply_alias(mut self, pre: &str) -> Self {\n        self.query().exprs_mut_for_each(|sel| {\n            match &sel.alias {\n                Some(alias) => {\n                    let alias = format!(\"{}{}\", pre, alias.to_string().as_str());\n                    sel.alias = Some(alias.into_iden());\n                }\n                None => {\n                    let col = match &sel.expr {\n                        SimpleExpr::Column(col_ref) => match col_ref.column() {\n                            Some(col) => col,\n                            None => {\n                                panic!(\"cannot apply alias for Column with asterisk\");\n                            }\n                        },\n                        SimpleExpr::AsEnum(_, simple_expr) => match simple_expr.as_ref() {\n                            SimpleExpr::Column(col_ref) => match col_ref.column() {\n                                Some(col) => col,\n                                None => {\n                                    panic!(\"cannot apply alias for AsEnum with asterisk\")\n                                }\n                            },\n                            _ => {\n                                panic!(\"cannot apply alias for AsEnum with expr other than Column\")\n                            }\n                        },\n                        _ => panic!(\"cannot apply alias for expr other than Column or AsEnum\"),\n                    };\n                    let alias = format!(\"{}{}\", pre, col.to_string().as_str());\n                    sel.alias = Some(alias.into_iden());\n                }","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/query/combine.rs#L40-L76","documentation":"Select::apply_alias() prefixes each selected column's alias, but a selection whose expression is a Column with the asterisk wildcard (e.g. Column::Asterisk / select all columns) has no single concrete column to prefix, so it is rejected. The at-fault input is a query selecting an asterisk column being passed through select_also/select_with-style calls that need aliased results.","triggerScenarios":"Thrown at sea-orm-sync/src/query/combine.rs:58 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Select explicit columns instead of the asterisk wildcard before using select_also/select_with/select_two_required.","Expand the wildcard into the entity's individual columns manually so each gets its own alias.","Construct the aliased join query directly with join + column selections instead of relying on apply_alias."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e29bcd1b417c41a553b386fe94511d7c64a1c8ec","analyzedAt":"2026-09-10T11:31:52.468Z","contentChangedAt":"2026-09-10T11:31:52.468Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}