Skip to main content

Crate sqlmodel_core

Crate sqlmodel_core 

Source
Expand description

Core types and traits for SQLModel Rust.

sqlmodel-core is the foundation layer for the entire ecosystem. It defines the traits and core data types that all other crates build on.

§Role In The Architecture

  • Contract layer: Model and Connection are the primary traits implemented by user models and database drivers.
  • Data model: Row, Value, and SqlType represent query inputs/outputs and are shared across query, schema, and driver crates.
  • Structured concurrency: re-exports Cx and Outcome from asupersync so every async database operation is cancel-correct and budget-aware.

§Who Uses This Crate

  • sqlmodel-macros generates Model implementations defined here.
  • sqlmodel-query consumes Model metadata and Value to build SQL.
  • sqlmodel-schema inspects Model metadata to generate DDL.
  • sqlmodel-session depends on Connection, Row, and Value for unit-of-work flows.
  • Driver crates (sqlmodel-postgres, sqlmodel-mysql, sqlmodel-sqlite) implement Connection and operate on Row/Value.

Most applications should use the sqlmodel facade; reach for sqlmodel-core directly when writing drivers or advanced integrations.

Re-exports§

pub use connection::Connection;
pub use connection::Dialect;
pub use connection::IsolationLevel;
pub use connection::PreparedStatement;
pub use connection::Transaction;
pub use connection::TransactionInternal;
pub use connection::TransactionOps;
pub use error::Error;
pub use error::FieldValidationError;
pub use error::Result;
pub use error::ValidationError;
pub use error::ValidationErrorKind;
pub use field::Column;
pub use field::Field;
pub use field::FieldInfo;
pub use field::InheritanceInfo;
pub use field::InheritanceStrategy;
pub use field::ReferentialAction;
pub use hybrid::Hybrid;
pub use identifiers::quote_ident;
pub use identifiers::quote_ident_mysql;
pub use identifiers::sanitize_identifier;
pub use model::AttributeChange;
pub use model::AutoIncrement;
pub use model::ExtraFieldsBehavior;
pub use model::Model;
pub use model::ModelConfig;
pub use model::ModelEvents;
pub use model::SoftDelete;
pub use model::Timestamps;
pub use relationship::Lazy;
pub use relationship::LazyLoader;
pub use relationship::LinkTableInfo;
pub use relationship::PassiveDeletes;
pub use relationship::Related;
pub use relationship::RelatedMany;
pub use relationship::RelationshipInfo;
pub use relationship::RelationshipKind;
pub use relationship::find_back_relationship;
pub use relationship::find_relationship;
pub use relationship::validate_back_populates;
pub use row::Row;
pub use types::SqlEnum;
pub use types::SqlType;
pub use types::TypeInfo;
pub use validate::DumpMode;
pub use validate::DumpOptions;
pub use validate::DumpResult;
pub use validate::ModelDump;
pub use validate::ModelValidate;
pub use validate::SqlModelDump;
pub use validate::SqlModelValidate;
pub use validate::ValidateInput;
pub use validate::ValidateOptions;
pub use validate::ValidateResult;
pub use validate::apply_serialization_aliases;
pub use validate::apply_validation_aliases;
pub use value::Value;

Modules§

connection
Database connection traits.
dynamic
Dynamic model creation at runtime.
error
Error types for SQLModel operations.
field
Field and column definitions.
hybrid
Hybrid properties: values computed in Rust that also have SQL expression equivalents.
identifiers
SQL identifier quoting and sanitization utilities.
model
Model trait for ORM-style struct mapping.
relationship
Relationship metadata for SQLModel Rust.
row
Database row representation.
types
SQL type definitions and mapping.
validate
Runtime validation helpers for SQLModel.
value
Dynamic SQL values.

Structs§

Budget
A budget constraining resource usage for a task or region.
Cx
The capability context for a task.
RegionId
A unique identifier for a region in the runtime.
TaskId
A unique identifier for a task in the runtime.

Enums§

Outcome
The four-valued outcome of a concurrent operation.