fix(sidebar): keep partition pagination at schema root

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-07-14 01:07:17 +08:00
1 parent 8cbd41e021
commit e51004d79c
3 files changed
+37 -5

No files matched your search

+29
View File
@@ -29,6 +29,35 @@ describe("PostgreSQL overloaded routines", () => {
});
});
describe("PostgreSQL table hierarchy", () => {
it("keeps schema pagination visible at the table-group root when a page ends inside nested partitions", () => {
const nodes = buildTableTreeNodes({
...context,
schema: "public",
tables: [
{ name: "orders", table_type: "BASE TABLE", comment: null },
{ name: "orders_2026", table_type: "BASE TABLE", comment: null, parent_schema: "public", parent_name: "orders" },
{ name: "orders_2026_01", table_type: "BASE TABLE", comment: null, parent_schema: "public", parent_name: "orders_2026" },
],
});
const loadMore: TreeNode = {
id: "load-more:1000",
label: "tree.loadMore",
type: "load-more",
connectionId: context.connectionId,
database: context.database,
loadMore: { parentId: "connection:db:__tables", offset: 1000, pageSize: 1000 },
};
const withLoadMore = appendTableTreeLoadMoreNode(nodes, loadMore, { schema: "public", name: "orders_2026" });
expect(withLoadMore.map((node) => node.label)).toEqual(["orders", "tree.loadMore"]);
const yearPartition = tablePartitionGroups(withLoadMore[0])[0].children?.[0];
expect(yearPartition?.label).toBe("orders_2026");
expect(tablePartitionGroups(yearPartition!)[0].children?.map((node) => node.label)).toEqual(["orders_2026_01"]);
});
});
describe("TDengine table hierarchy", () => {
it("groups child tables under their supertable and keeps ordinary tables flat", () => {
const tables: TableInfo[] = [
+4 -1
View File
@@ -353,7 +353,10 @@ function findTableTreeNode(nodes: readonly TreeNode[], parent: TableTreeLoadMore
export function appendTableTreeLoadMoreNode(children: TreeNode[], loadMoreNode: TreeNode, parent?: TableTreeLoadMoreParent): TreeNode[] {
const parentNode = parent ? findTableTreeNode(children, parent) : undefined;
const childGroup = parentNode ? tablePartitionGroups(parentNode)[0] : undefined;
// Only TDengine pages are scoped to a STABLE's child-table group. PostgreSQL
// paginates the whole schema, so nesting its global cursor under whichever
// partition happens to end the page can hide all remaining schema objects.
const childGroup = parentNode && isSuperTable(parentNode) ? tablePartitionGroups(parentNode)[0] : undefined;
if (!childGroup) return [...children, loadMoreNode];
childGroup.children = [...(childGroup.children ?? []), loadMoreNode];