Custom ColumnTypes - PostgreSQL Interval Value
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 9.9k
- Forks
- 734
- Avg merge
- 6h 36m
- Merged PRs (30d)
- 8
Description
Is it currently possible to use other types such as (Pg) Interval?
I found the Custom Variant in the Docs, but is this meant to map back to existing sea_orm::Values or can it be used to access other types than the predefined ones?
Is there currently a way to use other types than the listed ones or would they have to be implemented in sea_orm first?
Edit:
What I was able to work out so far:
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "mytable")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
#[sea_orm(column_type = "Custom(\"interval\".to_owned())")]
pub duration: String
}
myobject::ActiveModel {
duration: Set(String::from("00:10:00")),
..Default::default()
}
.save(db)
.await.expect("oops");
This doesn't seem to make it work:
oops: Query("error returned from database: Column »duration« has type interval, but the expression has type text")
Am I missing something? Do I need a custom type instead of String?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the Custom ColumnType documentation and the PostgreSQL interval example in the issue. Determine how interval values should map to SeaORM values rather than text, and consider the database error a failure case; done means interval values can be persisted without the type mismatch.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, rust
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100