pub enum Backend {
Mysql,
Postgres,
Sqlite,
}Expand description
支持的数据库后端
Variants§
Implementations§
Source§impl Backend
impl Backend
Sourcepub fn quote_ident(&self, ident: &str) -> String
pub fn quote_ident(&self, ident: &str) -> String
双重引号标识符
Sourcepub fn double_type(&self) -> &'static str
pub fn double_type(&self) -> &'static str
双精度浮点类型名(§9.7「数值归 double」)
SUM/AVG 的结果在不同后端原生精度不同:MySQL AVG(<int 列>) 只保留 4 位小数
(DECIMAL(scale+4)),PG AVG(<int 列>) 返回精确 numeric,均与 Mongo $avg
的 IEEE-754 double 存在差异。故 SQL 侧 AVG 前先把入参 CAST 到双精度。
Sourcepub fn qualified_table(&self, namespace: Option<&str>, table: &str) -> String
pub fn qualified_table(&self, namespace: Option<&str>, table: &str) -> String
表名 → SQL:namespace 可选限定(Some(ns) → "ns"."table";None → "table")
namespace 与连接的 search_path / 连接库 / ATTACH 库对应(见
multi-datasource-routing-plan.md §二);空串按 None 处理。
Sourcepub fn placeholder(&self, _index: usize) -> String
pub fn placeholder(&self, _index: usize) -> String
占位符:SQLite/MySQL 用 ?,PostgreSQL 用 $n(调用方保证按顺序传入 index)
Sourcepub fn supports_returning(&self) -> bool
pub fn supports_returning(&self) -> bool
MySQL 无 RETURNING —— 需由 Host 编排 UPDATE + find 两段;PG/SQLite 原生支持
Sourcepub fn json_type_name(&self) -> &'static str
pub fn json_type_name(&self) -> &'static str
JSON 列的方言类型名(object/array 字段落单列存储的契约,见 §4.5 / 不足清单 #3)
⚠️ 跨方言对齐:object/array 字段在 SQL 后端以单列存 JSON 文本 ——
MySQL JSON / PG jsonb / SQLite TEXT(JSON1 扩展)。core 不写 DDL(铁律 6),
此常量供示例 DDL、introspection 与文档约定引用。
Sourcepub fn json_extract_scalar(&self, col: &str, path: &[&str]) -> String
pub fn json_extract_scalar(&self, col: &str, path: &[&str]) -> String
JSON 点号路径 → 标量提取表达式(U3 对象点号路径过滤 / U4 排序用)
- MySQL:
JSON_UNQUOTE(JSON_EXTRACT(col, '$.a.b')) - PG:
(col #>> '{a,b}') - SQLite:
json_extract(col, '$.a.b')
三者统一为「提取后标量(数值/字符串)」,供比较与 ORDER BY 使用;
col 须为已按后端引号化的列标识符,path 为点号各段(不含列名)。