fix(neo4j): pick node identity function by server version
This commit is contained in:
25 files changed
+461
-30
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { joinedRowChanges, type JoinedWriteSource } from "../../dataGrid/joinedRowChanges";
|
||||
import { joinedRowChanges, joinedSaveOptions, type JoinedWriteSource } from "../../dataGrid/joinedRowChanges";
|
||||
|
||||
const sources: JoinedWriteSource[] = [
|
||||
{ tableKey: "users", primaryKeys: ["id"], sourceColumns: ["id", "name", undefined, undefined] },
|
||||
@@ -79,3 +79,22 @@ describe("joined row updates", () => {
|
||||
).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe("joined save options", () => {
|
||||
it("keeps the connected server version so saved rows are addressed like the rows that were read", () => {
|
||||
const options = joinedSaveOptions([{ tableMeta: { tableName: "events", primaryKeys: ["id"] }, sourceColumns: ["id", "name"] }], {
|
||||
databaseType: "neo4j",
|
||||
serverVersion: "Neo4j/4.4.44",
|
||||
identifierQuote: "`",
|
||||
includeDatabaseName: false,
|
||||
columns: ["id", "name"],
|
||||
rows: [[1, "user"]],
|
||||
dirtyRows: new Map([[0, new Map([[1, "renamed"]])]]),
|
||||
newRows: [],
|
||||
deletedRows: new Set(),
|
||||
});
|
||||
expect(options).toHaveLength(1);
|
||||
expect(options[0]!.serverVersion).toBe("Neo4j/4.4.44");
|
||||
expect(options[0]!.databaseType).toBe("neo4j");
|
||||
});
|
||||
});
|
||||
@@ -25,6 +25,9 @@ export interface DataGridColumnInfo {
|
||||
|
||||
export interface DataGridSaveStatementOptions {
|
||||
databaseType?: DatabaseType;
|
||||
/** Server version reported by the connection (see `BuildTableSelectSqlOptions.serverVersion`).
|
||||
* The saved statements must address rows the same way the grid read them. */
|
||||
serverVersion?: string;
|
||||
identifierQuote?: string;
|
||||
tableMeta: DataGridTableMeta;
|
||||
columns: string[];
|
||||
|
||||
@@ -9,7 +9,7 @@ export interface JoinedSaveTarget {
|
||||
/** Feed per-source changes through the existing SQL builder, including undo SQL. */
|
||||
export function joinedSaveOptions(
|
||||
targets: JoinedSaveTarget[],
|
||||
options: Pick<DataGridSaveStatementOptions, "databaseType" | "identifierQuote" | "columns" | "includeDatabaseName"> & {
|
||||
options: Pick<DataGridSaveStatementOptions, "databaseType" | "serverVersion" | "identifierQuote" | "columns" | "includeDatabaseName"> & {
|
||||
rows: CellValue[][];
|
||||
dirtyRows: Map<number, Map<number, CellValue>>;
|
||||
newRows: CellValue[][];
|
||||
@@ -24,6 +24,7 @@ export function joinedSaveOptions(
|
||||
}));
|
||||
return joinedRowChanges(sources, options.rows, options.dirtyRows).map((update) => ({
|
||||
databaseType: options.databaseType,
|
||||
serverVersion: options.serverVersion,
|
||||
identifierQuote: options.identifierQuote,
|
||||
columns: options.columns,
|
||||
tableMeta: targets[update.sourceIndex]!.tableMeta,
|
||||
|
||||
@@ -13,6 +13,10 @@ import type { SqlSemanticToken } from "@/lib/sql/semantic/types";
|
||||
export interface BuildTableSelectSqlOptions {
|
||||
databaseType?: DatabaseType;
|
||||
driverProfile?: string;
|
||||
/** Server version reported by the connection (for example `Neo4j/4.4.44`). Engines that
|
||||
* renamed a built-in function across releases (Neo4j below 5 uses `id()` where 5+ uses
|
||||
* `elementId()`) need it to generate SQL the connected server understands. */
|
||||
serverVersion?: string;
|
||||
identifierQuote?: string;
|
||||
schema?: string;
|
||||
tableName: string;
|
||||
|
||||
Reference in new issue
Block a user