Skip to main content

drizzle_types/mysql/
mod.rs

1//! `MySQL` type definitions.
2//!
3//! The supported server baseline is MySQL 8.0.31. This module models MySQL's
4//! native type families without treating PostgreSQL-only concepts such as
5//! arrays, `JSONB`, or named enum types as portable.
6
7pub mod ddl;
8mod sql_type;
9mod type_category;
10
11/// Zero-sized SQL type markers for the MySQL dialect.
12///
13/// These markers are used by `drizzle-core` to distinguish MySQL's signed and
14/// unsigned integer widths, text and binary families, and temporal types at
15/// compile time. They carry no runtime type declaration details such as a
16/// length, precision, scale, or inline enum values. Use [`MySQLType`] when
17/// schema metadata needs those details.
18pub mod types {
19    macro_rules! mysql_markers {
20        ($($name:ident),+ $(,)?) => {
21            $(
22                #[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash)]
23                pub struct $name;
24            )+
25        };
26    }
27
28    mysql_markers!(
29        TinyInt,
30        TinyIntUnsigned,
31        SmallInt,
32        SmallIntUnsigned,
33        MediumInt,
34        MediumIntUnsigned,
35        Int,
36        IntUnsigned,
37        BigInt,
38        BigIntUnsigned,
39        Float,
40        Double,
41        Decimal,
42        Boolean,
43        Char,
44        Varchar,
45        TinyText,
46        Text,
47        MediumText,
48        LongText,
49        Binary,
50        Varbinary,
51        TinyBlob,
52        Blob,
53        MediumBlob,
54        LongBlob,
55        Json,
56        Date,
57        Time,
58        DateTime,
59        Timestamp,
60        Year,
61        Enum,
62        Set,
63        Bit,
64        Any,
65    );
66
67    /// MySQL accepts `INTEGER` as an alias for `INT`.
68    pub type Integer = Int;
69    /// MySQL accepts `INTEGER UNSIGNED` as an alias for `INT UNSIGNED`.
70    pub type IntegerUnsigned = IntUnsigned;
71    /// MySQL accepts `NUMERIC` as an alias for `DECIMAL`.
72    pub type Numeric = Decimal;
73}
74
75pub use sql_type::MySQLType;
76pub use type_category::{MySQLTypeCategory, TypeCategory};