SeaQL / SeaQL/sea-orm

VarBinary(16) column breaks DeriveEntityModel derive

Open
#2,316 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs-repro
Dominant language
Rust
Stars
9.9k
Forks
734
Avg merge
6h 36m
Merged PRs (30d)
8

Description

Description

After successfully importing the entity for a table containing a VarBinary(16) field, I am unable to build due to an error originating from the DeriveEntityModel derive in the entities Model struct.

Steps to Reproduce

  1. Import a table with a VarBinary(16) column
  2. Attempt to build with 'cargo build'
Expected Behavior

Program builds.

Actual Behavior
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "EventLog")]
pub struct Model {
    #[sea_orm(primary_key, unique)]
    pub event_log_id: i32,
    pub event_type_id: i32,
    pub user: String,
    pub timestamp: DateTime,
    #[sea_orm(column_type = "VarBinary(16)")]
    pub ip_address: Vec<u8>,
    pub event: Json,
}

error[E0308]: mismatched types
--> src\entities\event_log.rs:5:35
|
5 | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
| ^^^^^^^^^^^^^^^^^
| |
| expected StringLen, found integer
| arguments to this enum variant are incorrect

Reproduces How Often

Every time.

Workarounds

None.

Versions

MySQL 8.0.35 compiled for Linux (x86_64)
Windows 11 Version 10.0.22631 Build 22631

sea-orm v1.0.0
sea-orm-macros v1.0.0 (proc-macro)
sea-bae v0.2.0 (proc-macro)
sea-query v0.31.0
sea-query-binder v0.6.0
sea-query v0.31.0 (*)

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

Start by reproducing the failure with cargo build using the generated src/entities/event_log.rs Model and its VarBinary(16) column_type. Read the DeriveEntityModel derive involved in the error and verify the generated entity compiles successfully with the Vec field; done means the reported E0308 mismatch no longer occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.