pub struct SqlParser;Expand description
SQL 解析器(对标 Java JSqlParser + CCJSqlParserUtil)。
使用正则表达式进行轻量级 SQL 解析。 生产版本可替换为完整的 SQL parser(如 sqlparser-rs crate)。
Implementations§
Source§impl SqlParser
impl SqlParser
Sourcepub fn get_count_sql(sql: &str) -> String
pub fn get_count_sql(sql: &str) -> String
获取 COUNT SQL(对标 ISqlParser.getOriginalCountSql())。
将 SELECT ... FROM ... 转为 SELECT COUNT(*) FROM ...。
如果包含 GROUP BY,则包装为子查询。
Sourcepub fn replace_select_star(sql: &str, columns: &[&str]) -> String
pub fn replace_select_star(sql: &str, columns: &[&str]) -> String
优化 SELECT *(对标 SelectItemVisitorAdapter + 列裁剪)。
如果 SQL 是 SELECT *,可以替换为具体列名。
Auto Trait Implementations§
impl Freeze for SqlParser
impl RefUnwindSafe for SqlParser
impl Send for SqlParser
impl Sync for SqlParser
impl Unpin for SqlParser
impl UnsafeUnpin for SqlParser
impl UnwindSafe for SqlParser
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more