fix(oceanbase): use rowid for keyless Oracle rows
This commit is contained in:
1 parent
86a6846b10
commit
002dbbf602
12 files changed
+234
-17
No files matched your search
@@ -10,7 +10,7 @@ import { useHistoryStore } from "@/stores/historyStore";
|
||||
import { useProductionSafetyStore } from "@/stores/productionSafetyStore";
|
||||
import { assessProductionSql, productionContextForDatabase } from "@/lib/database/productionSafety";
|
||||
import type { ColumnInfo, DatabaseType } from "@/types/database";
|
||||
import { DBX_NEO4J_ELEMENT_ID_COLUMN, DBX_ROWID_COLUMN } from "@/lib/table/tableEditing";
|
||||
import { DBX_NEO4J_ELEMENT_ID_COLUMN, usesSyntheticRowIdKey } from "@/lib/table/tableEditing";
|
||||
import { effectiveDatabaseTypeForConnection } from "@/lib/database/jdbcDialect";
|
||||
|
||||
interface RowItem {
|
||||
@@ -862,7 +862,7 @@ export function useDataGridEditor(options: UseDataGridEditorOptions) {
|
||||
}
|
||||
|
||||
function shouldClearClonedColumn(columnName: string, columnInfo: ColumnInfo | undefined): boolean {
|
||||
if (resolvedDatabaseType.value === "oracle" && columnName.toUpperCase() === DBX_ROWID_COLUMN) return true;
|
||||
if (usesSyntheticRowIdKey(resolvedDatabaseType.value, [columnName])) return true;
|
||||
if (resolvedDatabaseType.value === "neo4j" && columnName === DBX_NEO4J_ELEMENT_ID_COLUMN) return true;
|
||||
const extra = columnInfo?.extra ?? "";
|
||||
const columnDefault = columnInfo?.column_default ?? "";
|
||||
|
||||
@@ -15,7 +15,7 @@ import { expandNestedJsonStringsForCopy } from "@/lib/common/jsonCopyValue";
|
||||
import { buildMongoCopyDocumentFromOriginal, buildMongoCopyInsertDocument, formatMongoShellLiteral, type MongoInputValue } from "@/lib/mongo/mongoDocumentValues";
|
||||
import type { DatabaseType, QueryResult } from "@/types/database";
|
||||
import type { QueryResultExportRequest } from "@/lib/backend/api";
|
||||
import { DBX_ROWID_COLUMN } from "@/lib/table/tableEditing";
|
||||
import { usesSyntheticRowIdKey } from "@/lib/table/tableEditing";
|
||||
import { buildXlsxSqlWorksheet } from "@/lib/export/xlsxSqlSheet";
|
||||
|
||||
/**
|
||||
@@ -1385,7 +1385,7 @@ function effectiveColumns(sourceColumns: Array<string | undefined> | undefined,
|
||||
}
|
||||
|
||||
function isCopyInsertOmittedColumn(databaseType: DatabaseType | undefined, column: string, tableMeta: DataGridTableMeta | undefined): boolean {
|
||||
if (databaseType === "oracle" && column.toUpperCase() === DBX_ROWID_COLUMN) return true;
|
||||
if (usesSyntheticRowIdKey(databaseType, [column])) return true;
|
||||
const columnInfo = tableMeta?.columns?.find((item) => normalizeColumnName(item.name) === normalizeColumnName(column));
|
||||
const normalizedType = columnInfo?.data_type.trim().replace(/^"|"$/g, "").toLowerCase();
|
||||
if (databaseType === "postgres" && (normalizedType === "tsvector" || normalizedType?.endsWith(".tsvector"))) return true;
|
||||
|
||||
@@ -38,9 +38,11 @@ function index(columns: string[], isUnique = true, filter: string | null = null)
|
||||
}
|
||||
|
||||
describe("tableEditing", () => {
|
||||
it("does not synthesize Oracle ROWID for views", () => {
|
||||
it("synthesizes ROWID only for Oracle-compatible base tables", () => {
|
||||
expect(editablePrimaryKeys("oracle", [column("ID"), column("NAME")], "VIEW")).toEqual([]);
|
||||
expect(editablePrimaryKeys("oracle", [column("ID"), column("NAME")], "TABLE")).toEqual([DBX_ROWID_COLUMN]);
|
||||
expect(editablePrimaryKeys("oceanbase-oracle", [column("ID"), column("NAME")], "TABLE")).toEqual([DBX_ROWID_COLUMN]);
|
||||
expect(editablePrimaryKeys("oceanbase-oracle", [column("ID", true), column("NAME")], "TABLE")).toEqual(["ID"]);
|
||||
});
|
||||
|
||||
it("treats view data tabs as readonly", () => {
|
||||
@@ -50,6 +52,8 @@ describe("tableEditing", () => {
|
||||
it("does not include Oracle ROWID for view data tabs", () => {
|
||||
expect(usesSyntheticRowIdKey("oracle", [DBX_ROWID_COLUMN], "VIEW")).toBe(false);
|
||||
expect(usesSyntheticRowIdKey("oracle", [DBX_ROWID_COLUMN], "MATERIALIZED_VIEW")).toBe(false);
|
||||
expect(usesSyntheticRowIdKey("oceanbase-oracle", [DBX_ROWID_COLUMN], "TABLE")).toBe(true);
|
||||
expect(usesSyntheticRowIdKey("oceanbase-oracle", [DBX_ROWID_COLUMN], "VIEW")).toBe(false);
|
||||
});
|
||||
|
||||
it("allows keyless row predicates only for databases that support them", () => {
|
||||
|
||||
@@ -124,6 +124,9 @@ const DATABASE_CAPABILITY_OVERRIDES: Partial<Record<DatabaseType, Partial<Databa
|
||||
oracle: {
|
||||
syntheticKey: "oracle-rowid",
|
||||
},
|
||||
"oceanbase-oracle": {
|
||||
syntheticKey: "oracle-rowid",
|
||||
},
|
||||
trino: {
|
||||
tableData: {
|
||||
insert: true,
|
||||
|
||||
@@ -91,7 +91,8 @@ export function hiveTablePropertiesIndicateTransactional(result: { rows: readonl
|
||||
|
||||
export function usesSyntheticRowIdKey(databaseType: DatabaseType | undefined, primaryKeys: string[], tableType?: string): boolean {
|
||||
if (isViewTableType(tableType)) return false;
|
||||
return primaryKeys.length === 1 && ((databaseType === "oracle" && primaryKeys[0].toUpperCase() === DBX_ROWID_COLUMN) || (databaseType === "neo4j" && primaryKeys[0] === DBX_NEO4J_ELEMENT_ID_COLUMN));
|
||||
const syntheticKey = getDatabaseCapability(databaseType).syntheticKey;
|
||||
return primaryKeys.length === 1 && ((syntheticKey === "oracle-rowid" && primaryKeys[0].toUpperCase() === DBX_ROWID_COLUMN) || (syntheticKey === "neo4j-element-id" && primaryKeys[0] === DBX_NEO4J_ELEMENT_ID_COLUMN));
|
||||
}
|
||||
|
||||
export function isHiddenGridColumn(databaseType: DatabaseType | undefined, column: string, primaryKeys: string[], tableType?: string): boolean {
|
||||
|
||||
Reference in new issue
Block a user