drizzle_types/mysql/mod.rs
1//! `MySQL` types. The supported server baseline is MySQL 8.0.31.
2//!
3//! - [`types`]: zero-sized SQL type markers used for compile-time checks.
4//! - [`MySQLType`]: column types as written in DDL, including signedness and
5//! inline `ENUM`/`SET` values.
6//! - [`TypeCategory`]: how a Rust field type maps to a `MySQL` column.
7//! - [`MySQLTypeCategory`]: families of SQL type declarations, used when parsing.
8//! - [`ddl`]: schema objects (tables, columns, indexes, ...) for migrations.
9//! - [`names`]: default constraint names that fit `MySQL` identifiers.
10//! - [`default`]: the canonical `DEFAULT` clause spelling shared by every
11//! schema producer.
12//!
13//! PostgreSQL-only concepts such as arrays, `JSONB` and named enum types have
14//! no `MySQL` equivalent here.
15
16pub mod ddl;
17pub mod default;
18pub mod names;
19mod sql_type;
20mod type_category;
21
22/// Zero-sized SQL type markers for the `MySQL` dialect.
23///
24/// Each marker stands for one SQL type at compile time, named after it
25/// (`IntUnsigned` is `INT UNSIGNED`, `Any` is untyped SQL such as a raw `SQL`
26/// fragment). Markers carry no length, precision or `ENUM` values; see
27/// [`MySQLType`] for those. The traits in [`crate::sql`] say which markers
28/// can be compared, assigned, or used in arithmetic.
29pub mod types {
30 macro_rules! mysql_markers {
31 ($($name:ident),+ $(,)?) => {
32 $(
33 #[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash)]
34 pub struct $name;
35 )+
36 };
37 }
38
39 mysql_markers!(
40 TinyInt,
41 TinyIntUnsigned,
42 SmallInt,
43 SmallIntUnsigned,
44 MediumInt,
45 MediumIntUnsigned,
46 Int,
47 IntUnsigned,
48 BigInt,
49 BigIntUnsigned,
50 Float,
51 Double,
52 Decimal,
53 Boolean,
54 Char,
55 Varchar,
56 TinyText,
57 Text,
58 MediumText,
59 LongText,
60 Binary,
61 Varbinary,
62 TinyBlob,
63 Blob,
64 MediumBlob,
65 LongBlob,
66 Json,
67 Date,
68 Time,
69 DateTime,
70 Timestamp,
71 Year,
72 Enum,
73 Set,
74 Bit,
75 Any,
76 );
77
78 /// MySQL accepts `INTEGER` as an alias for `INT`.
79 pub type Integer = Int;
80 /// MySQL accepts `INTEGER UNSIGNED` as an alias for `INT UNSIGNED`.
81 pub type IntegerUnsigned = IntUnsigned;
82 /// MySQL accepts `NUMERIC` as an alias for `DECIMAL`.
83 pub type Numeric = Decimal;
84}
85
86pub use default::canonical_default;
87pub use sql_type::MySQLType;
88pub use type_category::{MySQLTypeCategory, TypeCategory};