fix(xugu): enable safe row editing without primary keys
This commit is contained in:
1 parent
39b2d2a6ac
commit
3e75be87eb
17 files changed
+236
-50
No files matched your search
@@ -64,6 +64,21 @@ describe("editable query hidden primary keys", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("supports Xugu's unqualified ROWID expression for keyless base tables", () => {
|
||||
expect(
|
||||
buildQueryWithHiddenPrimaryKeys({
|
||||
sql: "SELECT * FROM APP.USERS t WHERE t.ACTIVE = 1",
|
||||
databaseType: "xugu",
|
||||
primaryKeys: ["__DBX_ROWID"],
|
||||
existingResultNames: ["ID", "NAME"],
|
||||
sourceExpressions: { __DBX_ROWID: "ROWID" },
|
||||
}),
|
||||
).toEqual({
|
||||
sql: 'SELECT *, ROWID AS "__DBX_PK_0" FROM APP.USERS t WHERE t.ACTIVE = 1',
|
||||
projections: [{ sourceName: "__DBX_ROWID", alias: "__DBX_PK_0" }],
|
||||
});
|
||||
});
|
||||
|
||||
it("preserves an Oracle FOR UPDATE clause when appending a hidden row key", () => {
|
||||
expect(
|
||||
buildQueryWithHiddenPrimaryKeys({
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
DBX_NEO4J_ELEMENT_ID_COLUMN,
|
||||
DBX_ROWID_COLUMN,
|
||||
DBX_TDENGINE_TBNAME_COLUMN,
|
||||
canInsertTableRows,
|
||||
canDeleteExistingTdengineRows,
|
||||
canEditExistingTableRows,
|
||||
canUseKeylessRowPredicate,
|
||||
@@ -13,6 +14,7 @@ import {
|
||||
isTdengineExistingRowReadonlyColumn,
|
||||
isTableDataEditable,
|
||||
supportsDataGridTransaction,
|
||||
shouldIncludeSyntheticRowId,
|
||||
usesSyntheticRowIdKey,
|
||||
} from "@/lib/table/tableEditing";
|
||||
import type { ColumnInfo, IndexInfo } from "@/types/database";
|
||||
@@ -46,6 +48,29 @@ describe("tableEditing", () => {
|
||||
expect(editablePrimaryKeys("oceanbase-oracle", [column("ID", true), column("NAME")], "TABLE")).toEqual(["ID"]);
|
||||
});
|
||||
|
||||
it("uses Xugu ROWID for ordinary, partitioned, and temporary tables but not views", () => {
|
||||
const columns = [column("ID"), column("VALUE")];
|
||||
expect(editablePrimaryKeys("xugu", columns, "TABLE")).toEqual([DBX_ROWID_COLUMN]);
|
||||
expect(editablePrimaryKeys("xugu", columns, "PARTITIONED TABLE")).toEqual([DBX_ROWID_COLUMN]);
|
||||
expect(editablePrimaryKeys("xugu", columns, "TEMPORARY TABLE")).toEqual([DBX_ROWID_COLUMN]);
|
||||
expect(editablePrimaryKeys("xugu", columns, "VIEW")).toEqual([]);
|
||||
expect(usesSyntheticRowIdKey("xugu", [DBX_ROWID_COLUMN], "TABLE")).toBe(true);
|
||||
expect(usesSyntheticRowIdKey("xugu", [DBX_ROWID_COLUMN], "PARTITIONED TABLE")).toBe(true);
|
||||
expect(usesSyntheticRowIdKey("xugu", [DBX_ROWID_COLUMN], "TEMPORARY TABLE")).toBe(true);
|
||||
expect(usesSyntheticRowIdKey("xugu", [DBX_ROWID_COLUMN], "VIEW")).toBe(false);
|
||||
expect(isTableDataEditable("xugu", [DBX_ROWID_COLUMN], "TABLE")).toBe(true);
|
||||
expect(isTableDataEditable("xugu", [DBX_ROWID_COLUMN], "VIEW")).toBe(false);
|
||||
expect(canInsertTableRows("xugu")).toBe(true);
|
||||
});
|
||||
|
||||
it("includes Xugu ROWID while cold table metadata has no declared primary keys", () => {
|
||||
expect(shouldIncludeSyntheticRowId("xugu", [], "TABLE")).toBe(true);
|
||||
expect(shouldIncludeSyntheticRowId("xugu", [], "PARTITIONED TABLE")).toBe(true);
|
||||
expect(shouldIncludeSyntheticRowId("xugu", [], "TEMPORARY TABLE")).toBe(true);
|
||||
expect(shouldIncludeSyntheticRowId("xugu", [], "VIEW")).toBe(false);
|
||||
expect(shouldIncludeSyntheticRowId("oracle", [], "TABLE")).toBe(false);
|
||||
});
|
||||
|
||||
it("treats view data tabs as readonly", () => {
|
||||
expect(isTableDataEditable("oracle", [DBX_ROWID_COLUMN], "VIEW")).toBe(false);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user