fix(oceanbase-oracle): bound first query result page
This commit is contained in:
1 parent
b5bf45e224
commit
30d8b3970a
8 files changed
+258
-14
No files matched your search
@@ -0,0 +1,36 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { QueryResult } from "@/types/database";
|
||||
import { stripPaginationRowNumber } from "@/lib/query/queryPaginationResult";
|
||||
|
||||
const result: QueryResult = {
|
||||
columns: ["__dbx_row_num", "shape", "__dbx_row_num"],
|
||||
rows: [["user value", "POINT(1 2)", 101]],
|
||||
column_types: ["VARCHAR", "GEOMETRY", "NUMBER"],
|
||||
column_sortables: [true, false, true],
|
||||
spatial_columns: [{ column_index: 1, srid: 4326 }],
|
||||
spatial_values: [[null, 4326, null]],
|
||||
large_value_cells: [{ row_index: 0, column_index: 1, original_bytes: 200 }],
|
||||
hidden_column_indexes: [0],
|
||||
affected_rows: 0,
|
||||
execution_time_ms: 1,
|
||||
};
|
||||
|
||||
describe("pagination result columns", () => {
|
||||
it("removes only the generated trailing column and keeps user columns and metadata aligned", () => {
|
||||
const cleaned = stripPaginationRowNumber(result, "__dbx_row_num");
|
||||
expect(cleaned.columns).toEqual(["__dbx_row_num", "shape"]);
|
||||
expect(cleaned.rows).toEqual([["user value", "POINT(1 2)"]]);
|
||||
expect(cleaned.column_types).toEqual(["VARCHAR", "GEOMETRY"]);
|
||||
expect(cleaned.column_sortables).toEqual([true, false]);
|
||||
expect(cleaned.spatial_values).toEqual([[null, 4326]]);
|
||||
expect(cleaned.spatial_columns).toEqual(result.spatial_columns);
|
||||
expect(cleaned.large_value_cells).toEqual(result.large_value_cells);
|
||||
expect(cleaned.hidden_column_indexes).toEqual([0]);
|
||||
expect(result.columns).toHaveLength(3);
|
||||
});
|
||||
|
||||
it("leaves user results untouched when the plan has no helper or the trailing name differs", () => {
|
||||
expect(stripPaginationRowNumber(result, undefined)).toBe(result);
|
||||
expect(stripPaginationRowNumber(result, "different_helper")).toBe(result);
|
||||
});
|
||||
});
|
||||
@@ -438,6 +438,7 @@ export interface QueryPaginationExecutionPlan {
|
||||
countSql?: string;
|
||||
exactQueryRowBound?: number;
|
||||
useAgentResultSession: boolean;
|
||||
paginationRowNumberColumn?: string;
|
||||
}
|
||||
|
||||
export type QuerySortDirection = "asc" | "desc";
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { QueryResult } from "@/types/database";
|
||||
|
||||
/** Remove only the trailing helper identified by the pagination plan. */
|
||||
export function stripPaginationRowNumber(result: QueryResult, column: string | undefined): QueryResult {
|
||||
const index = result.columns.length - 1;
|
||||
if (!column || index < 0 || result.columns[index] !== column) return result;
|
||||
return {
|
||||
...result,
|
||||
columns: result.columns.slice(0, index),
|
||||
rows: result.rows.map((row) => row.slice(0, index)),
|
||||
column_types: result.column_types?.slice(0, index),
|
||||
column_sortables: result.column_sortables?.slice(0, index),
|
||||
spatial_values: result.spatial_values?.map((row) => row.slice(0, index)),
|
||||
spatial_columns: result.spatial_columns?.filter((column) => column.column_index < index),
|
||||
large_value_cells: result.large_value_cells?.filter((cell) => cell.column_index < index),
|
||||
hidden_column_indexes: result.hidden_column_indexes?.filter((columnIndex) => columnIndex < index),
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user