Skip to content

Commit 165c5a8

Browse files
committed
feat: limit query
1 parent 6d5a2cb commit 165c5a8

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src-tauri/src/cmd.rs

+11
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ pub struct DialectPayload {
2929
pub cwd: Option<String>,
3030
}
3131

32+
#[allow(clippy::unused_async)]
33+
pub fn get_ast_dialect(dialect: &str) -> Box<dyn sqlparser::dialect::Dialect> {
34+
match dialect {
35+
"folder" | "file" | "duckdb" => Box::new(sqlparser::dialect::DuckDbDialect {}),
36+
"clickhouse" => Box::new(sqlparser::dialect::ClickHouseDialect {}),
37+
"mysql" => Box::new(sqlparser::dialect::MySqlDialect {}),
38+
"postgres" => Box::new(sqlparser::dialect::PostgreSqlDialect {}),
39+
_ => Box::new(sqlparser::dialect::GenericDialect {}),
40+
}
41+
}
42+
3243
#[allow(clippy::unused_async)]
3344
pub async fn get_dialect(
3445
DialectPayload {

src-tauri/src/dialect/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,13 @@ pub async fn _paging_query(
198198
if let Some(ref _stmt) = stmt {
199199
sql = ast::limit_stmt(dialect, _stmt, limit, offset).unwrap_or(sql);
200200
}
201-
let mut res = d.query_all(&sql).await?;
201+
let mut res = d.query(&sql, 0, 0).await?;
202202

203203
// get total row count
204204
if let Some(ref _stmt) = stmt {
205205
if let Some(count_sql) = ast::count_stmt(dialect, _stmt) {
206-
if let Ok(count) = d._sql_row_count(&count_sql).await {
206+
log::info!("count_sql: {count_sql}");
207+
if let Ok(count) = d.query_count(&count_sql).await {
207208
res.total = count;
208209
};
209210
}

src-tauri/src/dialect/sqlite.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::convert::From;
22
use std::sync::Arc;
33

44
use arrow::array::*;
5-
use arrow::datatypes::*;
65
use arrow::datatypes::{DataType, Field, Schema};
76
use async_trait::async_trait;
87
use rusqlite::types::Value;

0 commit comments

Comments
 (0)