25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(influxdb): prefill new-query with rolling time window
Clarence02430d1b092d
diff --git a/apps/desktop/src/lib/__tests__/sql/newQueryContext.spec.ts b/apps/desktop/src/lib/__tests__/sql/newQueryContext.spec.tsindex 8c7d8368e1..fef4782f1c 100644--- a/apps/desktop/src/lib/__tests__/sql/newQueryContext.spec.ts+++ b/apps/desktop/src/lib/__tests__/sql/newQueryContext.spec.ts@@ -212,6 +212,20 @@ describe("buildSelectAllSql", () => {expect(buildSelectAllSql("jdbc", { schema: "APP", tableName: "USERS" }, '"', "phoenix")).toBe('SELECT * FROM "APP"."USERS"');});+ it("scopes InfluxDB 1.x / 2.x prefill to a rolling InfluxQL window", () => {+ // Without a time predicate the InfluxQL query would scan every shard+ // for the measurement before LIMIT clips the tail; the 5-minute+ // window matches the sidebar quick-open default so users can run+ // the prefill safely.+ expect(buildSelectAllSql("influxdb", { tableName: "cpu" })).toBe('SELECT * FROM "cpu" WHERE time > now() - 5m ORDER BY time DESC LIMIT 100');+ });++ it("scopes InfluxDB 3.x prefill to a rolling DataFusion INTERVAL window", () => {+ // v3 goes through DataFusion SQL and needs an ANSI INTERVAL literal+ // rather than the InfluxQL Go-duration form used by v1 / v2.+ expect(buildSelectAllSql("influxdb3", { tableName: "cpu" })).toBe(`SELECT * FROM "cpu" WHERE time > now() - INTERVAL '5 minutes' ORDER BY time DESC LIMIT 100`);+ });+it("bracket-quotes a SQL Server table", () => {expect(buildSelectAllSql("sqlserver", { schema: "dbo", tableName: "users" })).toBe("SELECT * FROM [dbo].[users]");expect(buildSelectAllSql("sqlserver", { tableName: "users" })).toBe("SELECT * FROM [users]");diff --git a/apps/desktop/src/lib/sql/newQueryContext.ts b/apps/desktop/src/lib/sql/newQueryContext.tsindex 1409be7a12..a4a0fbbdb1 100644--- a/apps/desktop/src/lib/sql/newQueryContext.ts+++ b/apps/desktop/src/lib/sql/newQueryContext.ts@@ -147,10 +147,24 @@ export function resolveNewQueryTable(input: ResolveNewQueryTableInput): NewQuery* Builds a `SELECT * FROM <table>` statement for the new-query prefill, reusing* the same per-dialect identifier quoting and schema/catalog qualification used* by the table-data view.+ *+ * Time-series engines get the same rolling-window scoping the sidebar+ * quick-open uses (see `default_time_series_predicate` in+ * `crates/dbx-core/src/sql_dialect/table_select.rs`). Without a `time`+ * predicate InfluxDB scans every shard (v1/v2) or every Parquet file+ * (v3), which turns "let me draft a query against this table" into a+ * full-history scan the moment the user hits Run. VictoriaMetrics+ * already has its own metric range template above.*/export function buildSelectAllSql(databaseType: DatabaseType | undefined, table: Pick<NewQueryTable, "schema" | "catalog" | "tableName"> & Partial<Pick<NewQueryTable, "database">>, identifierQuote?: string, driverProfile?: string, includeDatabaseName = false): string {if (databaseType === "victoriametrics") return metricRangeQuery(table.tableName);const ref = qualifiedTableName({ databaseType, driverProfile, identifierQuote, database: table.database, schema: table.schema, catalog: table.catalog, tableName: table.tableName, includeDatabaseName });+ if (databaseType === "influxdb") {+ return `SELECT * FROM ${ref} WHERE time > now() - 5m ORDER BY time DESC LIMIT 100`;+ }+ if (databaseType === "influxdb3") {+ return `SELECT * FROM ${ref} WHERE time > now() - INTERVAL '5 minutes' ORDER BY time DESC LIMIT 100`;+ }return `SELECT * FROM ${ref}`;}