fix(mysql): strip CLI \G suffix before executing queries
This commit is contained in:
5 files changed
+82
-8
No files matched your search
@@ -106,6 +106,14 @@ describe("queryStore MySQL grouped-result editing", () => {
|
||||
expect(listIndexes).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("strips the MySQL CLI vertical-output suffix only from the submitted SQL", async () => {
|
||||
const sourceSql = "SHOW CREATE FUNCTION fun_grade \\G;";
|
||||
const tab = await executeGrouped(sourceSql, ["Create Function"]);
|
||||
|
||||
expect(executeMulti.mock.calls[0]?.[2]).toBe("SHOW CREATE FUNCTION fun_grade;");
|
||||
expect(tab.lastExecutedSql).toBe(sourceSql);
|
||||
});
|
||||
|
||||
it("identifies the FROM root independently of metadata completion order", async () => {
|
||||
getColumns.mockImplementation(async (_connectionId: string, _database: string, _schema: string, table: string) => {
|
||||
if (table === "users") await new Promise((resolve) => setTimeout(resolve, 10));
|
||||
|
||||
@@ -132,4 +132,29 @@ describe("queryStore query result export", () => {
|
||||
|
||||
expect(request?.useAgentCursor).toBe(true);
|
||||
});
|
||||
|
||||
it("strips the MySQL CLI vertical-output suffix from export re-execution SQL", async () => {
|
||||
mocks.getConfig.mockReturnValue({ id: "mysql-1", name: "MySQL", db_type: "mysql", database: "app", query_timeout_secs: 30 });
|
||||
const { useQueryStore } = await import("@/stores/queryStore");
|
||||
const store = useQueryStore();
|
||||
const tabId = store.createTab("mysql-1", "app", "Query");
|
||||
const tab = store.tabs.find((item) => item.id === tabId)!;
|
||||
tab.sql = "SHOW CREATE FUNCTION fun_grade \\G";
|
||||
tab.lastExecutedSql = tab.sql;
|
||||
tab.result = {
|
||||
columns: ["Create Function"],
|
||||
rows: [["definition"]],
|
||||
affected_rows: 0,
|
||||
execution_time_ms: 1,
|
||||
};
|
||||
|
||||
const request = await store.buildQueryResultExportRequest(tabId, {
|
||||
exportId: "export-g",
|
||||
filePath: "fun.csv",
|
||||
format: "csv",
|
||||
});
|
||||
|
||||
expect(request?.sql).toBe("SHOW CREATE FUNCTION fun_grade");
|
||||
expect(request?.queryBaseSql).toBe("SHOW CREATE FUNCTION fun_grade");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user