sz-orm-core 3.5.0

Core ORM engine: Model trait, ActiveRecord, QueryBuilder, Pool, Transaction, migration, and SQL dialect abstraction
Documentation
[package]

name = "sz-orm-core"

description = "Core ORM engine: Model trait, ActiveRecord, QueryBuilder, Pool, Transaction, migration, and SQL dialect abstraction"

version.workspace = true

edition.workspace = true

authors.workspace = true

license.workspace = true

repository.workspace = true

homepage.workspace = true

keywords.workspace = true

categories.workspace = true



[features]

# 默认启用 Redis 分布式缓存后端(RedisBackend),开箱即用

default = ["redis"]

testing = ["tokio/full"]

# 启用 query! 宏的编译期连真实 DB 验证能力(转发至 sz-orm-macros/db-verify)

db-verify = ["sz-orm-macros/db-verify"]

# 启用 L2Cache 的 Redis 分布式后端(Fix #39:真实实现,基于 redis 0.27 + tokio-comp + connection-manager)

redis = ["dep:redis"]

# #88 修复:断路器与 ORM 执行路径集成(引入 sz-orm-health 的 CircuitBreaker)

circuit-breaker = ["sz-orm-health"]

# #93 修复:限流器与 ORM 执行路径集成(引入 sz-orm-limit 的 RateLimiter)

rate-limit = ["sz-orm-limit"]

# v3.2.0:连接池自动预热增强(渐进式分批 + 多池统一 + 进度可观测)

auto-prewarm = []

# v3.2.0:查询计划缓存(SQL 解析/优化结果缓存 + LRU 淘汰 + 表级失效)

plan-cache = ["dep:sqlparser", "dep:xxhash-rust"]

# v3.2.0:零拷贝序列化(BorrowedValue + ColumnarResultSet)

zero-copy = []

# v3.2.0:SIMD 加速(批量整数解码 + 列比较 + 自动降级)

simd = ["dep:wide"]

# v3.3.0:多租户与数据隔离增强(租户上下文自动注入 + Schema 隔离 + 连接池隔离 + 行级安全 + 列级脱敏 + 多租户审计)

multi-tenant-enhanced = ["dep:sz-orm-audit", "dep:sz-orm-masking"]

# v3.3.0:分布式缓存一致性(跨实例失效 + Write-behind + 缓存击穿/雪崩防护)

dist-cache = ["dep:bloomfilter", "dep:rand", "dep:sz-orm-crypto"]

# v3.4.0:测试覆盖补齐门禁矩阵标识(不引入依赖,仅用于 feature 组合编译门禁)

test-coverage = []

# v3.4.0:架构改进门禁矩阵标识(不引入依赖,仅用于 feature 组合编译门禁)

arch-improvement = []

# v3.4.0:文档补全门禁矩阵标识(不引入依赖,仅用于 feature 组合编译门禁)

doc-completion = []

# v3.4.0:SmallString 优化(CompactString 替代 String,短字符串 ≤ 23 字节内联存储)

perf-smallstring = ["dep:compact_str"]

# v3.4.0:enum dispatch 优化(match 分发替代 Box<dyn Dialect> vtable 查找)

perf-enum-dispatch = []

# v3.4.0:L2 缓存零拷贝推广(BorrowedValue + ColumnarResultSet 推广到 L2 缓存路径)

perf-zero-copy-l2 = ["zero-copy"]

# v3.4.0:Box<str> 优化(Value::BoxedStr 变体,节省 8 字节/值 capacity 字段)

perf-box-str = []

# v3.4.0:类型安全列引用(Column<T> + Schema derive 列名常量)

type-safe-columns = ["sz-orm-macros/type-safe-columns"]

# v3.4.0:类型化列(Column<T> 独立 feature,允许仅启用 Column<T> 不启用 Schema 扩展)

typed-column = []

# v3.4.0:类型化 DSL(typed_ast.rs Diesel 风格表达式 DSL)

typed-dsl = []

# v3.5.0:L1 缓存(Session 级别 Identity Map + LRU + AtomicU64 统计)

l1-cache = []

# v3.5.0:CockroachDB 方言(PG 兼容分布式数据库,委派 PostgreSqlDialect)

dialect-cockroachdb = []

# v3.5.0:YugabyteDB 方言(PG 兼容分布式数据库,委派 PostgreSqlDialect)

dialect-yugabytedb = []

# v3.4.0:迁移指南门禁矩阵标识(纯文档,不引入依赖)

migration-guide = []



[dependencies]

async-trait.workspace = true

tracing.workspace = true

thiserror.workspace = true

serde.workspace = true

serde_json.workspace = true

chrono.workspace = true

bytes.workspace = true

tokio = { workspace = true, features = ["sync", "time", "rt", "macros"] }

# P3-4 修复:使用 parking_lot::RwLock 替换 std::sync::RwLock,消除锁毒化风险

# parking_lot 的 RwLock 不会返回 PoisonError,无需 unwrap(),且性能更好

parking_lot.workspace = true

# v1.1.0 优化 2:Pool 无锁队列(crossbeam-queue::ArrayQueue 替换 Mutex<VecDeque>)

crossbeam-queue.workspace = true

# 流式查询:Connection::query_stream 默认实现需要 futures::stream::empty

futures.workspace = true

sz-orm-sql-validator = { version = "3.5.0", path = "../sz-orm-sql-validator" }

sz-orm-macros = { version = "3.5.0", path = "../sz-orm-macros" }

# #88 修复:可选断路器依赖(启用 circuit-breaker feature 时生效)

sz-orm-health = { version = "3.5.0", path = "../sz-orm-health", optional = true }

# #93 修复:可选限流器依赖(启用 rate-limit feature 时生效)

sz-orm-limit = { version = "3.5.0", path = "../sz-orm-limit", optional = true }

# Fix #39:L2Cache RedisBackend 真实实现(启用 redis feature 时生效)

# 使用 connection-manager 自动重连 + tokio-comp 异步 IO

redis = { workspace = true, optional = true }

# v3.2.0:查询计划缓存(plan-cache feature)

sqlparser = { workspace = true, optional = true }

xxhash-rust = { workspace = true, optional = true }

# v3.2.0:SIMD 加速(simd feature)

wide = { workspace = true, optional = true }

# v3.3.0:多租户审计增强(multi-tenant-enhanced feature)

sz-orm-audit = { version = "3.5.0", path = "../sz-orm-audit", optional = true }

# v3.3.0:列级脱敏增强(multi-tenant-enhanced feature)

sz-orm-masking = { version = "3.5.0", path = "../sz-orm-masking", optional = true }

# v3.3.0:分布式缓存布隆过滤器防护(dist-cache feature)

bloomfilter = { workspace = true, optional = true }

# v3.3.0:分布式缓存随机 TTL 雪崩防护(dist-cache feature)

rand = { workspace = true, optional = true }

# v3.3.0:WAL 加密(dist-cache feature)

sz-orm-crypto = { version = "3.5.0", path = "../sz-orm-crypto", optional = true }

# v3.4.0:SmallString 优化(perf-smallstring feature)

compact_str = { workspace = true, optional = true }



[dev-dependencies]

tokio = { workspace = true, features = ["full", "test-util"] }

sqlx = { version = "0.9", default-features = false, features = ["runtime-tokio", "tls-rustls", "mysql", "postgres", "sqlite", "chrono", "json"] }

rusqlite = { version = "0.32", features = ["bundled"] }

# DuckDB 真实集成测试(bundled:编译 DuckDB 源码,需 MSVC + CMake)

duckdb = { version = "1", features = ["bundled"] }

oracle = { version = "0.6", default-features = false, features = ["chrono"] }

# v2.0.0 任务 1.2:SQL Server 真实集成测试(tiberius 0.12 异步驱动)

# 仅启用 tds73 + chrono,不启用 TLS(本地开发环境;生产环境应启用 rustls 或 native-tls)

tiberius = { version = "0.12", default-features = false, features = ["tds73", "chrono"] }

# tiberius 0.12 需要 tokio-util compat 适配 tokio TcpStream

tokio-util = { version = "0.7", features = ["compat"] }

criterion = { version = "0.5", features = ["html_reports", "async_tokio"] }

# v0.2.1 修复 T-1:Property-Based Testing

proptest = { workspace = true }



[lib]

name = "sz_orm_core"

path = "src/lib.rs"



[[test]]

name = "core_tests"

path = "tests/core.rs"



[[test]]

name = "integration_sqlite"

path = "tests/integration_sqlite.rs"



[[test]]

name = "integration_mysql"

path = "tests/integration_mysql.rs"



[[test]]

name = "integration_pg"

path = "tests/integration_pg.rs"



[[test]]

name = "integration_oracle"

path = "tests/integration_oracle.rs"



# v2.0.0 任务 1.2:SQL Server 集成测试入口

[[test]]

name = "integration_mssql"

path = "tests/integration_mssql.rs"



[[test]]

name = "contracts"

path = "tests/contracts.rs"



# v0.2.1 修复 T-1:Property-Based Testing 入口

[[test]]

name = "property"

path = "tests/property.rs"



# v0.2.1 阶段十五:Soak Test 入口(默认 ignored,CI 24h 任务运行)

[[test]]

name = "soak"

path = "tests/soak.rs"



# 连接池混沌工程测试

[[test]]

name = "chaos_pool"

path = "tests/chaos_pool.rs"



# v3.3.0 多租户竞态与跨租户泄漏测试

[[test]]

name = "tenant_concurrency"

path = "tests/tenant_concurrency.rs"

required-features = ["multi-tenant-enhanced"]



# v3.2.0 查询计划缓存差分测试(需 plan-cache feature)

[[test]]

name = "plan_cache_differential"

path = "tests/plan_cache_differential.rs"

required-features = ["plan-cache"]



# v3.1.0 SIMD 差分测试(需 simd feature)

[[test]]

name = "simd_differential"

path = "tests/simd_differential.rs"

required-features = ["simd"]



# v3.2.0 连接池预热集成测试(需 auto-prewarm feature)

[[test]]

name = "prewarm_integration"

path = "tests/prewarm_integration.rs"

required-features = ["auto-prewarm"]



[[test]]

name = "smallstring_differential"

path = "tests/smallstring_differential.rs"



[[test]]

name = "type_safe_columns"

path = "tests/type_safe_columns.rs"

required-features = ["type-safe-columns"]



# M2: typed_ast DSL 46 种表达式测试(需 typed-dsl feature)

[[test]]

name = "typed_ast_aggregate"

path = "tests/typed_ast_aggregate_test.rs"

required-features = ["typed-dsl"]



[[test]]

name = "typed_ast_arithmetic"

path = "tests/typed_ast_arithmetic_test.rs"

required-features = ["typed-dsl"]



[[test]]

name = "typed_ast_string"

path = "tests/typed_ast_string_test.rs"

required-features = ["typed-dsl"]



[[test]]

name = "typed_ast_date"

path = "tests/typed_ast_date_test.rs"

required-features = ["typed-dsl"]



[[test]]

name = "typed_ast_zst_diff"

path = "tests/typed_ast_zst_diff_test.rs"

required-features = ["typed-dsl"]



# M2: L1 缓存测试(需 l1-cache feature)

[[test]]

name = "l1_cache"

path = "tests/l1_cache_test.rs"

required-features = ["l1-cache"]



[[test]]

name = "l1_l2_db"

path = "tests/l1_l2_db_test.rs"

required-features = ["l1-cache"]



# M5: CockroachDB 方言测试(需 dialect-cockroachdb feature)

[[test]]

name = "dialect_cockroachdb"

path = "tests/dialect_cockroachdb_test.rs"

required-features = ["dialect-cockroachdb"]



# M5: YugabyteDB 方言测试(需 dialect-yugabytedb feature)

[[test]]

name = "dialect_yugabytedb"

path = "tests/dialect_yugabytedb_test.rs"

required-features = ["dialect-yugabytedb"]



[[bench]]

name = "smallstring_bench"

path = "benches/smallstring_bench.rs"

harness = false



[[bench]]

name = "enum_dispatch_bench"

path = "benches/enum_dispatch_bench.rs"

harness = false



[[bench]]

name = "zero_copy_l2_bench"

path = "benches/zero_copy_l2_bench.rs"

harness = false



[[bench]]

name = "box_str_bench"

path = "benches/box_str_bench.rs"

harness = false



[[bench]]

name = "typed_overhead_bench"

path = "benches/typed_overhead_bench.rs"

harness = false



# M2: L1 缓存性能基准(需 l1-cache feature)

[[bench]]

name = "l1_cache_bench"

path = "benches/l1_cache_bench.rs"

harness = false

required-features = ["l1-cache"]



[[bench]]

name = "core_bench"

path = "benches/core_bench.rs"

harness = false



[[bench]]

name = "zero_copy_bench"

path = "benches/zero_copy_bench.rs"

harness = false

required-features = ["zero-copy"]



[[bench]]

name = "simd_bench"

path = "benches/simd_bench.rs"

harness = false

required-features = ["simd"]



[package.metadata.docs.rs]

all-features = true

rustdoc-args = ["--cfg", "docsrs"]



[lints]

workspace = true