Skip to main content

sqlx_gen/introspect/
mod.rs

1pub mod mysql;
2pub mod postgres;
3pub mod sqlite;
4
5#[derive(Debug, Clone, Default)]
6#[allow(unused)]
7pub struct ColumnInfo {
8    pub name: String,
9    /// High-level data type (e.g. "integer", "character varying")
10    pub data_type: String,
11    /// Underlying type name: udt_name (PG), column_type (MySQL), declared type (SQLite)
12    pub udt_name: String,
13    /// Schema in which `udt_name` is defined.
14    ///
15    /// Populated by the Postgres backend (e.g. `auth` for an `auth.role` enum
16    /// column, `pg_catalog` for builtins). `None` for MySQL/SQLite which have
17    /// no per-type namespacing. Used to disambiguate enums/composites/domains
18    /// when two schemas declare a type with the same name.
19    pub udt_schema: Option<String>,
20    pub is_nullable: bool,
21    pub is_primary_key: bool,
22    pub ordinal_position: i32,
23    pub schema_name: String,
24    /// Raw column default expression (e.g. `'idle'::task_status`)
25    pub column_default: Option<String>,
26}
27
28#[derive(Debug, Clone)]
29pub struct TableInfo {
30    pub schema_name: String,
31    pub name: String,
32    pub columns: Vec<ColumnInfo>,
33}
34
35#[derive(Debug, Clone)]
36pub struct EnumInfo {
37    pub schema_name: String,
38    pub name: String,
39    pub variants: Vec<String>,
40    /// Default variant name (raw SQL value, e.g. "idle"), if any column uses this enum with a DEFAULT.
41    pub default_variant: Option<String>,
42}
43
44#[derive(Debug, Clone)]
45pub struct CompositeTypeInfo {
46    pub schema_name: String,
47    pub name: String,
48    pub fields: Vec<ColumnInfo>,
49}
50
51#[derive(Debug, Clone)]
52pub struct DomainInfo {
53    pub schema_name: String,
54    pub name: String,
55    /// The underlying SQL type
56    pub base_type: String,
57}
58
59#[derive(Debug, Clone, Default)]
60pub struct SchemaInfo {
61    pub tables: Vec<TableInfo>,
62    pub views: Vec<TableInfo>,
63    pub enums: Vec<EnumInfo>,
64    pub composite_types: Vec<CompositeTypeInfo>,
65    pub domains: Vec<DomainInfo>,
66}