fix(doris): preserve aggregate-state bytes in query results
This commit is contained in:
1 parent
4bcab01489
commit
c75ce783df
17 files changed
+1066
-42
No files matched your search
@@ -51,11 +51,13 @@ function createEditorWithResult(
|
||||
mongoCollectionGrid = false,
|
||||
quickEntry = false,
|
||||
editable = ref(true),
|
||||
resultColumnTypes?: string[],
|
||||
) {
|
||||
let editor: ReturnType<typeof useDataGridEditor>;
|
||||
const result = ref<{ columns: string[]; rows: CellValue[][] }>({
|
||||
const result = ref<{ columns: string[]; rows: CellValue[][]; column_types?: string[] }>({
|
||||
columns: ["first", "hidden", "last"],
|
||||
rows: existingRows,
|
||||
column_types: resultColumnTypes,
|
||||
});
|
||||
|
||||
editor = useDataGridEditor({
|
||||
@@ -734,12 +736,66 @@ describe("useDataGridEditor appendPastedRowsToNewRow", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("keeps explicitly read-only mapped columns out of editing and paste", () => {
|
||||
const editor = createEditor(["first", "hidden", "last"], true, undefined, [0]);
|
||||
it("preserves ordinary read-only values when cloning while still blocking edits and paste", () => {
|
||||
const editor = createEditor(["first", "hidden", "last"], true, undefined, [0], [["Ada", "hidden", "Lovelace"]]);
|
||||
|
||||
expect(editor.canEditColumn(0)).toBe(false);
|
||||
expect(editor.canEditColumn(2)).toBe(true);
|
||||
expect(editor.appendPastedRowsToNewRow(-1, [["Ada"]], [0])).toEqual({ ok: false, reason: "readonly-column" });
|
||||
editor.applyCellValue(0, 0, null);
|
||||
expect(editor.dirtyRows.value.size).toBe(0);
|
||||
editor.cloneRow(0);
|
||||
expect(editor.newRows.value.at(-1)).toEqual(["Ada", "hidden", "Lovelace"]);
|
||||
});
|
||||
|
||||
it("clears opaque aggregate states when cloning and prefers the result type over metadata", () => {
|
||||
const opaque = createEditor(
|
||||
["first", "hidden", "last"],
|
||||
true,
|
||||
undefined,
|
||||
[1],
|
||||
[["Ada", "0x00ff", "Lovelace"]],
|
||||
undefined,
|
||||
[
|
||||
{ name: "first", data_type: "varchar" },
|
||||
{ name: "hidden", data_type: "varchar" },
|
||||
{ name: "last", data_type: "varchar" },
|
||||
],
|
||||
false,
|
||||
false,
|
||||
ref(true),
|
||||
["varchar", "agg_state<sum(int)>", "varchar"],
|
||||
);
|
||||
opaque.cloneRow(0);
|
||||
expect(opaque.newRows.value.at(-1)).toEqual(["Ada", null, "Lovelace"]);
|
||||
|
||||
const metadataFallback = createEditor(["first", "hidden", "last"], true, undefined, [1], [["Ada", "0x00ff", "Lovelace"]], undefined, [
|
||||
{ name: "first", data_type: "varchar" },
|
||||
{ name: "hidden", data_type: "agg_state<sum(int)>" },
|
||||
{ name: "last", data_type: "varchar" },
|
||||
]);
|
||||
metadataFallback.cloneRow(0);
|
||||
expect(metadataFallback.newRows.value.at(-1)).toEqual(["Ada", null, "Lovelace"]);
|
||||
|
||||
const resultTypeWins = createEditor(
|
||||
["first", "hidden", "last"],
|
||||
true,
|
||||
undefined,
|
||||
[1],
|
||||
[["Ada", "ordinary", "Lovelace"]],
|
||||
undefined,
|
||||
[
|
||||
{ name: "first", data_type: "varchar" },
|
||||
{ name: "hidden", data_type: "agg_state<sum(int)>" },
|
||||
{ name: "last", data_type: "varchar" },
|
||||
],
|
||||
false,
|
||||
false,
|
||||
ref(true),
|
||||
["varchar", "varchar", "varchar"],
|
||||
);
|
||||
resultTypeWins.cloneRow(0);
|
||||
expect(resultTypeWins.newRows.value.at(-1)).toEqual(["Ada", "ordinary", "Lovelace"]);
|
||||
});
|
||||
|
||||
it("fills following blank new rows before adding more rows", () => {
|
||||
|
||||
@@ -6,6 +6,7 @@ import type { CellValue } from "@/lib/dataGrid/cellValue";
|
||||
import { coerceDataGridCellValue, dataGridCellEditorText } from "@/lib/dataGrid/dataGridCellCoercion";
|
||||
import { focusDataGridEditorWithoutScrolling, preserveDataGridScrollPosition } from "@/lib/dataGrid/dataGridEditorFocus";
|
||||
import { normalizeDataGridSaveError } from "@/lib/dataGrid/dataGridSql";
|
||||
import { isOpaqueAggregateStateColumnType } from "@/lib/dataGrid/binaryCellDownload";
|
||||
import { rowStatusFilterAfterAddingRow, type RowStatusFilter } from "@/lib/dataGrid/gridRowStatus";
|
||||
import type { GridNewRowMeta, GridNewRowPlacement } from "@/lib/dataGrid/gridNewRowPlacement";
|
||||
import { supportsDataGridTransaction } from "@/lib/table/tableEditing";
|
||||
@@ -107,7 +108,7 @@ export interface DataGridSaveConfirmationRequest {
|
||||
}
|
||||
|
||||
export interface UseDataGridEditorOptions {
|
||||
result: ComputedRef<{ columns: string[]; rows: CellValue[][] }>;
|
||||
result: ComputedRef<{ columns: string[]; rows: CellValue[][]; column_types?: string[] }>;
|
||||
editable: ComputedRef<boolean | undefined>;
|
||||
databaseType: ComputedRef<DatabaseType | undefined>;
|
||||
connectionId: ComputedRef<string | undefined>;
|
||||
@@ -1331,7 +1332,10 @@ export function useDataGridEditor(options: UseDataGridEditorOptions) {
|
||||
return (columnIndex: number) => {
|
||||
const columnName = sourceColumns.value?.[columnIndex] ?? result.value.columns[columnIndex];
|
||||
if (columnName === undefined) return false;
|
||||
return shouldClearClonedColumn(columnName, columnInfoByName.get(columnName.toLowerCase()));
|
||||
const columnInfo = columnInfoByName.get(columnName.toLowerCase());
|
||||
const resultType = result.value.column_types?.[columnIndex]?.trim();
|
||||
if (isOpaqueAggregateStateColumnType(resultType || columnInfo?.data_type)) return true;
|
||||
return shouldClearClonedColumn(columnName, columnInfo);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user