fix(sqlserver): keep hidden-key sorting editable across pages
This commit is contained in:
1 parent
961d9683b9
commit
e5287f50b4
3 files changed
+44
-4
No files matched your search
@@ -569,6 +569,22 @@ describe("queryStore hidden primary key editing", () => {
|
||||
expect(tab.resultSortedSql).toBe("SELECT name, `id` AS `__DBX_PK_0` FROM users ORDER BY name ASC");
|
||||
await vi.waitFor(() => expect(tab.querySourceColumns).toEqual(["name", "id"]));
|
||||
expect(tab.queryAnalysis).toBeDefined();
|
||||
|
||||
await store.executeTabSql(tabId, "SELECT name FROM users", {
|
||||
resultBaseSql: "SELECT name FROM users",
|
||||
resultSortedSql: tab.resultSortedSql,
|
||||
querySort: {
|
||||
resultColumns: ["name"],
|
||||
columnIndex: 0,
|
||||
column: "name",
|
||||
direction: "asc",
|
||||
},
|
||||
pagination: { offset: 100, limit: 100 },
|
||||
});
|
||||
|
||||
await vi.waitFor(() => expect(tab.querySourceColumns).toEqual(["name", "id"]));
|
||||
expect(tab.queryEditabilityReason).toBeUndefined();
|
||||
expect(tab.result?.hidden_column_indexes).toEqual([1]);
|
||||
});
|
||||
|
||||
it("clears result sorting when the editor SQL is executed again", async () => {
|
||||
|
||||
@@ -3817,7 +3817,10 @@ export const useQueryStore = defineStore("query", () => {
|
||||
if (tab.mode === "query") {
|
||||
const prepared = await prepareEditableQueryExecution(tab, sqlToExecute, conn, effectiveDbType, executionDatabase, traceId, elapsed);
|
||||
sqlToExecute = prepared.sql;
|
||||
queryMetadataSql = prepared.metadataSql;
|
||||
// Database sorting executes a generated wrapper around the user's query.
|
||||
// Keep editability metadata anchored to the original query so the wrapper
|
||||
// does not turn an otherwise editable result into a complex read-only one.
|
||||
queryMetadataSql = options?.resultSortedSql && !options?.querySort ? queryBaseSql : prepared.metadataSql;
|
||||
hiddenPrimaryKeys = prepared.hiddenPrimaryKeys;
|
||||
if (options?.querySort) {
|
||||
const sorted = await api.buildSortedQuerySql({
|
||||
|
||||
Reference in new issue
Block a user