fix(sidebar): re-read displayed range when paging window drifts
This commit is contained in:
5 files changed
+352
-63
No files matched your search
+23
-1
@@ -1,5 +1,16 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { appendTableTreeLoadMoreNode, buildGroupedObjectTreeNodes, buildObjectGroupPlaceholderNodes, buildSimpleObjectTreeNodes, buildTableTreeNodes, mergeTableInfosIntoObjects, mergeTableTreePageChildren, tablePartitionGroups, withoutTableTreeLoadMoreNodes } from "@/lib/table/tableTree";
|
||||
import {
|
||||
appendTableTreeLoadMoreNode,
|
||||
buildGroupedObjectTreeNodes,
|
||||
buildObjectGroupPlaceholderNodes,
|
||||
buildSimpleObjectTreeNodes,
|
||||
buildTableTreeNodes,
|
||||
mergeTableInfosIntoObjects,
|
||||
mergeTableTreePageChildren,
|
||||
tablePageRowAnchorKey,
|
||||
tablePartitionGroups,
|
||||
withoutTableTreeLoadMoreNodes,
|
||||
} from "@/lib/table/tableTree";
|
||||
import type { ObjectInfo, TableInfo, TreeNode } from "@/types/database";
|
||||
|
||||
const context = {
|
||||
@@ -558,3 +569,14 @@ describe("TDengine table hierarchy", () => {
|
||||
expect(tablePartitionGroups(yearPartition!)[0].children?.map((node) => node.label)).toEqual(["catalog_nested_2024_asia", "catalog_nested_2024_eu"]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("tablePageRowAnchorKey", () => {
|
||||
it("identifies a paged row without depending on the server's casing", () => {
|
||||
expect(tablePageRowAnchorKey("Orders", "App", "Orders_2024")).toBe(tablePageRowAnchorKey("orders", "app", "orders_2024"));
|
||||
});
|
||||
|
||||
it("keeps a partition's parent in the key so same-named child tables stay distinct", () => {
|
||||
expect(tablePageRowAnchorKey("p_2024", "app", "orders")).not.toBe(tablePageRowAnchorKey("p_2024", "app", "customers"));
|
||||
expect(tablePageRowAnchorKey("p_2024", "app")).not.toBe(tablePageRowAnchorKey("p_2024", "app", "orders"));
|
||||
});
|
||||
});
|
||||
@@ -112,6 +112,18 @@ function foldedPartitionObjectLookupKey(objectType: string, schema: string | und
|
||||
return `${objectType}\0${(schema || "").toLowerCase()}\0${name.toLowerCase()}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Folded identity of one row of a paged object list. Paged loads remember the
|
||||
* row that was expected to open the next page (the peek row the previous page
|
||||
* fetched but did not show) so a window that shifted under concurrent DDL can be
|
||||
* detected before an unaligned page is appended. Kept case-insensitive on
|
||||
* purpose: an anchor must never look "changed" because the server cased a name
|
||||
* differently between two responses.
|
||||
*/
|
||||
export function tablePageRowAnchorKey(name: string, schema?: string | null, parentName?: string | null) {
|
||||
return `${(schema || "").toLowerCase()}\0${(parentName || "").toLowerCase()}\0${name.toLowerCase()}`;
|
||||
}
|
||||
|
||||
type PrefixSortInfo = {
|
||||
rootName: string;
|
||||
leadingSegments: number;
|
||||
|
||||
Reference in new issue
Block a user