Expand description
Generic data types for cross-database compatibility.
This module defines the unified DataType enum and all component types
(integer, decimal, float, boolean, string, binary, date/time, special, and
collection types) that serve as the foundation for SQL rendering across
all supported database platforms.
§Design Philosophy
- Abstract over database-specific implementations —
DataTypecaptures enough metadata to generate correct DDL for each target, but does not embed platform-specific syntax. - Preserve precision metadata — Decimal types carry precision and scale; string types carry length constraints; timestamp types carry fractional seconds precision.
- Every type renders somewhere — a dialect answers for every variant,
emulating a type it does not have (JSON stored as
NVARCHAR(MAX)on SQL Server, a struct stored asjsonbonPostgreSQL) rather than refusing.
§Type Categories
| Category | Types | Example |
|---|---|---|
| Integer | IntegerDataType | INT, BIGINT, TINYINT |
| Decimal | DecimalDataType | DECIMAL(19,4), DECIMAL(5,2) |
| Float | FloatDataType | REAL, DOUBLE |
| Boolean | BooleanDataType | BOOLEAN, BIT |
| String | CharDataType, VarCharDataType, TextDataType | VARCHAR(100), TEXT |
| Binary | BinaryDataType, VarBinaryDataType | BYTEA, VARBINARY |
| Date/Time | DateDataType, TimestampDataType, TimestampTzDataType | DATE, TIMESTAMP |
| Special | UuidDataType, JsonDataType | UUID, JSONB |
| Collection | ArrayDataType, MapDataType, StructDataType | INTEGER[], MAP<TEXT,INT>, STRUCT<a INT> |
§Usage
Convenience constructors for common types:
use razeri_plugin_contract::DataType;
let id = DataType::bigint();
let name = DataType::varchar(255);
let price = DataType::decimal(19, 4);
let created = DataType::timestamp();
// JSON with binary storage (JSONB in PostgreSQL, VARIANT in Snowflake)
let data = DataType::json();Each variant maps to platform-specific types as documented in the variant
definitions. Dialect plugins resolve the final SQL type string during
rendering; the rendering traits live in this crate’s renderer module.
Structs§
- Array
Data Type - Array type containing elements of another type.
- Binary
Data Type - Fixed-length binary data.
- Boolean
Data Type - Boolean data type (true/false).
- Char
Data Type - Fixed-length character string.
- Date
Data Type - Date only (year, month, day) without time component.
- Date
Time Data Type - Combined date and time for legacy compatibility.
- Decimal
Data Type - Exact numeric type with fixed precision and scale.
- Float
Data Type - Approximate floating-point numeric type.
- Integer
Data Type - Integer data type supporting signed/unsigned variants.
- Json
Data Type - JSON/Semi-structured data type.
- MapData
Type - Map/Dictionary type with key-value pairs.
- Struct
Data Type - Struct/record type: an ordered list of named fields.
- Struct
Field - One named field inside a
StructDataType, in the order it was declared. - Text
Data Type - Unbounded text type for large text storage.
- Time
Data Type - Time only without date component.
- Timestamp
Data Type - Timestamp (date and time) without timezone.
- Timestamp
TzData Type - Timestamp with timezone awareness.
- Uuid
Data Type - Universally Unique Identifier (UUID/GUID).
- VarBinary
Data Type - Variable-length binary data.
- VarChar
Data Type - Variable-length character string with optional max length.
Enums§
- Data
Type - Unified data type enumeration covering all supported types across databases.
- Data
Type Ref - Simplified data type reference used in CAST /
TRY_CAST/ CONVERT expressions. - Float
Precision - Floating point precision variants.
- Integer
Size - Integer size variants matching common database integer types.
- Interval
Data Type - Interval/duration type for time spans.
- Json
Storage Format - JSON storage format preference.
- String
Encoding - Character encoding for string types.