1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! ORM type aliases — semantic DB types that map to SQL.
//!
//! These are **transparent type aliases** (zero runtime cost). Users write them
//! in struct fields; the `#[model]` proc macro reads the **token name** to
//! determine the SQL column type for DDL generation and migrations.
//!
//! | Rust type | SQL (Postgres) | SQL (SQLite) |
//! |-----------------|----------------------|--------------|
//! | `Varchar` | VARCHAR(255) | TEXT |
//! | `Text` | TEXT | TEXT |
//! | `Timestamp` | TIMESTAMP | TEXT |
//! | `TimestampTz` | TIMESTAMPTZ | TEXT |
//! | `Date` | DATE | TEXT |
//! | `Decimal` | NUMERIC | REAL |
//! | `Json` | JSON | TEXT |
//! | `Jsonb` | JSONB | TEXT |
//! | `Bytes` | BYTEA | BLOB |
//!
//! Native Rust types also work: `i32` → INT, `i64` → BIGINT, `bool` → BOOLEAN,
//! `String` → VARCHAR(255), `f32` → REAL, `f64` → DOUBLE PRECISION.
// ── String types ──
/// Maps to `VARCHAR(255)`. Override length with `#[col(max = N)]`.
pub type Varchar = String;
/// Maps to `TEXT` — unlimited length string.
pub type Text = String;
// ── Temporal types ──
/// Maps to `TIMESTAMP` (without time zone).
pub type Timestamp = NaiveDateTime;
/// Maps to `TIMESTAMPTZ` (with time zone).
pub type TimestampTz = DateTime;
/// Maps to `DATE`.
pub type Date = NaiveDate;
// ── Numeric types ──
/// Maps to `NUMERIC`. Override precision/scale with `#[col(precision = N, scale = N)]`.
pub type Decimal = f64;
// ── Binary / JSON ──
/// Maps to `JSON`.
pub type Json = Value;
/// Maps to `JSONB`.
pub type Jsonb = Value;
/// Maps to `BYTEA` (Postgres) / `BLOB` (SQLite).
pub type Bytes = ;