{"record":{"id":"d7999a0c6324030b","repo":"SeaQL/sea-orm","slug":"owner-column-is-not-set","errorCode":null,"errorMessage":"Owner column is not set","messagePattern":"Owner column is not set","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sea-orm-sync/src/entity/relation.rs","lineNumber":473,"sourceCode":"    /// with `AND` (`ConditionType::All`, default) or `OR` (`ConditionType::Any`).\n    pub fn condition_type(mut self, condition_type: ConditionType) -> Self {\n        self.condition_type = condition_type;\n        self\n    }\n}\n\nimpl<E, R> From<RelationBuilder<E, R>> for RelationDef\nwhere\n    E: EntityTrait,\n    R: EntityTrait,\n{\n    fn from(b: RelationBuilder<E, R>) -> Self {\n        RelationDef {\n            rel_type: b.rel_type,\n            from_tbl: b.from_tbl,\n            to_tbl: b.to_tbl,\n            from_col: b.from_col.expect(\"Reference column is not set\"),\n            to_col: b.to_col.expect(\"Owner column is not set\"),\n            is_owner: b.is_owner,\n            skip_fk: b.skip_fk,\n            on_delete: b.on_delete,\n            on_update: b.on_update,\n            on_condition: b.on_condition,\n            fk_name: b.fk_name,\n            condition_type: b.condition_type,\n        }\n    }\n}\n\nmacro_rules! set_foreign_key_stmt {\n    ( $relation: ident, $foreign_key: ident ) => {\n        let from_cols: Vec<String> = $relation\n            .from_col\n            .into_iter()\n            .map(|col| {\n                let col_name = col.to_string();","sourceCodeStart":455,"sourceCodeEnd":491,"githubUrl":"https://github.com/SeaQL/sea-orm/blob/e29bcd1b417c41a553b386fe94511d7c64a1c8ec/sea-orm-sync/src/entity/relation.rs#L455-L491","documentation":"Mirror of error 174 for the other side: converting a `RelationBuilder` to `RelationDef` panics if `to_col` (the owner column, i.e. the target table's referenced column) was never set. Both `from_col` and `to_col` must be present for a well-formed relation.","triggerScenarios":"Building a relation dynamically and supplying only `from_col` (or only `to`), then converting to `RelationDef` — the `.expect(\"Owner column is not set\")` fires.","commonSituations":"Hand-assembling foreign keys in migrations; generating relations from metadata files where the referenced column entry is absent; typos in dynamic relation definitions.","solutions":["Call `.to_col(...)` on the RelationBuilder before conversion.","Check the relation definition includes both ends: `.from_col(fk).to_col(pk)`.","Prefer statically generated relation code over runtime assembly."],"exampleFix":"// before\nlet rel = Relation::BelongsTo.to(user::Entity).from_col(fk_col).into();\n// after\nlet rel = Relation::BelongsTo.to(user::Entity).from_col(fk_col).to_col(user::Column::Id).into();","handlingStrategy":"validation","validationCode":"// before converting: ensure both columns were supplied\nlet builder = Relation::BelongsTo.to(target).from_col(fk).to_col(pk); // to_col must not be omitted","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always supply .to_col(...) alongside .from_col(...) for belongs_to relations.","Check migration/metadata inputs for the referenced (owner) column before building relations.","Prefer code-generated relations over dynamic assembly."],"tags":["panic","relation","builder","missing-column"],"backgroundTag":"missing-required-argument","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"}