SeaQL / SeaQL/sea-orm

seaorm-cli codegen maps col(big_unsigned(..)) to i64

Open Beginner friendly
#2,494 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area:schema help-wanted
Dominant language
Rust
Stars
9.9k
Forks
735
Avg merge
6h 36m
Merged PRs (30d)
8

Description

Description

table clolumns with big_unsigned type get mapped to an i64 field during entity generation by seaorm-cli

Steps to Reproduce

  1. create a Table in a migration up with a BigUnsigned column
#[async_trait::async_trait]
impl MigrationTrait for Migration {
    async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
        manager
            .create_table(
                Table::create()
                    .table(User::Table)
                    .if_not_exists()
                    .col(pk_auto(User::Id))
                    .col(big_unsigned(User::DiscordId))
                    .to_owned(),
            )
            .await
    }

    async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
        manager
            .drop_table(Table::drop().table(User::Table).to_owned())
            .await
    }
}

#[derive(DeriveIden)]
enum User {
    Table,
    Id,
    DiscordId,
}
  1. run sea-orm-cli generate entity -o entity/src -l

generated user.rs:

//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.4

use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "user")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: i32,
    pub discord_id: i64,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}

impl ActiveModelBehavior for ActiveModel {}

Expected Behavior

pub discord_id: u64 in generated entity

Actual Behavior

pub discord_id: i64 in generated entity

Reproduces How Often

every time

Workarounds

Reproducible Example

see above

Versions

1.1.4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the shown migration and the sea-orm-cli generate entity -o entity/src -l entry point. Compare the generated user.rs model with the migration's big_unsigned column; done means the generated discord_id field uses u64 instead of i64.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, database
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.