dbcli 0.1.0

Convert SQL query results to JSON without struct mapping, supporting MySQL/PostgreSQL/SQLite/Odbc
Documentation
use serde::{Deserialize, Serialize};

/// Base metadata for a query result column, describing a single column's name, type, and index.
///
/// Returned by the `to_json` functions in each driver module under [`crate::to_json`].
/// Can be used for dynamic table header rendering on the frontend, type-aware formatting, etc.
///
/// # Example
///
/// ```rust,no_run
/// // Example columns returned by to_json:
/// // ColumnBaseInfo { name: "id",         type: "INT",     index: 0 }
/// // ColumnBaseInfo { name: "created_at", type: "DATETIME", index: 1 }
/// ```
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ColumnBaseInfo {
    /// Column name, matching the column name (or alias) from the SQL query.
    pub name: String,

    /// Database type name of the column.
    ///
    /// - MySQL: uppercase raw type, e.g. `"INT"`, `"VARCHAR"`, `"DATETIME"`
    /// - PostgreSQL: uppercase identifier normalized by [`crate::to_json::postgres::detect_pg_type`],
    ///   e.g. `"INT"`, `"TEXT"`, `"TIMESTAMP"`
    /// - SQLite: uppercase raw type, e.g. `"INTEGER"`, `"TEXT"`, `"REAL"`
    #[serde(rename = "type")]
    pub r#type: String,

    /// Zero-based index of the column in the query result (starts at 0).
    pub index: u64,
}