Skip to content

macro: #[derive(Model)] rejects Decimal / Time / Binary despite FieldType supporting them #524

@ujeenet

Description

@ujeenet

Summary

Surfaced by the E2E showcase Phase 3 (#522 follow-up). The macro's `detect_type` (rustango-macros/src/lib.rs:6309-6327) only accepts: `i16/i32/i64/f32/f64/bool/String/DateTime/NaiveDate/Uuid/serde_json::Value`. Adding a `Decimal` field fails with:

unsupported field type `Decimal`; v0.1 supports i32/i64/f32/f64/bool/String/DateTime/NaiveDate/Uuid/serde_json::Value, optionally wrapped in Option or Auto (Auto only on integers)

But the framework's `FieldType` enum supports `Decimal`, `Time`, and `Binary` — the dialect compilers emit DDL for them, `bind_match!` binds them, and `row_to_json` decodes them. The macro is the missing link.

Repro

```rust
#[derive(Model)]
#[rustango(table = "x")]
pub struct X {
#[rustango(primary_key)]
pub id: Auto,
pub price: rust_decimal::Decimal, // ← fails
}
```

Workaround

Use `i64` cents (multiply by 100). The showcase's `shop` app does this — `price_cents: i64` instead of `price: Decimal`.

Acceptance

  • `#[derive(Model)]` accepts `Decimal` → `FieldType::Decimal` → DDL `DECIMAL(P,S)` (Postgres/MySQL) / `NUMERIC` (SQLite).
  • `#[derive(Model)]` accepts `NaiveTime` → `FieldType::Time`.
  • `#[derive(Model)]` accepts `Vec` → `FieldType::Binary` (BYTEA/VARBINARY/BLOB).
  • Regression test in `crates/rustango/tests/macro_field_types.rs` (or sibling) inserts + retrieves each type across all 3 backends.

Metadata

Metadata

Assignees

No one assigned

    Labels

    django-parityDjango 6.0 parity gap (from docs.djangoproject.com/en/6.0 audit)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions