Skip to content

large composite key table #1294

@billy1624

Description

@billy1624

Discussed in #1293

Originally posted by meowser December 9, 2022
I have a table I am working with which has a very large composite primary key. When I auto-generate a model using sea-orm-cli the created model causes the following error:

the trait `ValueType` is not implemented for `(std::string::String, std::string::String, std::string::String, std::string::String, std::string::String, std::string::String, std::string::String)

Here is an example of the model:

use sea_orm::entity::prelude::*;                                                                                                                                                                                                                                                                                                                                             
                                                                                                                                                                                                                                                                                                                                                                             
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]                                                                                                                                                                                                                                                                                                                    
#[sea_orm(table_name = "example")]                                                                                                                                                                                                                                                                                                                                           
pub struct Model {                                                                                                                                                                                                                                                                                                                                                           
    #[sea_orm(primary_key, auto_increment = false)]                                                                                                                                                                                                                                                                                                                          
    pub a: String,                                                                                                                                                                                                                                                                                                                                                           
    #[sea_orm(primary_key, auto_increment = false)]                                                                                                                                                                                                                                                                                                                          
    pub b: String,                                                                                                                                                                                                                                                                                                                                                           
    #[sea_orm(primary_key, auto_increment = false)]                                                                                                                                                                                                                                                                                                                          
    pub c: String,                                                                                                                                                                                                                                                                                                                                                           
    #[sea_orm(primary_key, auto_increment = false)]                                                                                                                                                                                                                                                                                                                          
    pub d: String,                                                                                                                                                                                                                                                                                                                                                           
    #[sea_orm(primary_key, auto_increment = false)]                                                                                                                                                                                                                                                                                                                          
    pub e: String,                                                                                                                                                                                                                                                                                                                                                           
    #[sea_orm(primary_key, auto_increment = false)]                                                                                                                                                                                                                                                                                                                          
    pub f: String,                                                                                                                                                                                                                                                                                                                                                           
    #[sea_orm(primary_key, auto_increment = false)]                                                                                                                                                                                                                                                                                                                          
    pub g: String,                                                                                                                                                                                                                                                                                                                                                           
    pub h: String,                                                                                                                                                                                                                                                                                                                                                           
}                                                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                                                                                                             
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]                                                                                                                                                                                                                                                                                                                      
pub enum Relation {}                                                                                                                                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                                                                                                                             
impl ActiveModelBehavior for ActiveModel {}   

I notice if I take out one of the primary key attributes my code will compile, so I believe there is an six column primary key limit. I was wondering what would be the best approach for dealing with tables like this since I have quite a few tables with long composite keys, which I cannot change?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions