fix(neo4j): pick node identity function by server version
This commit is contained in:
25 files changed
+461
-30
No files matched your search
+6
@@ -97,4 +97,10 @@ describe("useDataGridEditor save SQL database qualification", () => {
|
||||
await createEditor(false).saveChanges();
|
||||
expect(mocks.prepareDataGridSave.mock.calls[1]![0]).toMatchObject({ includeDatabaseName: false });
|
||||
});
|
||||
|
||||
it("forwards the connected server version so saved statements match the read SQL (#10503)", async () => {
|
||||
mocks.getConfig.mockReturnValue({ database_info: { productVersion: "Neo4j/4.4.44" } });
|
||||
await createEditor(false).saveChanges();
|
||||
expect(mocks.prepareDataGridSave.mock.calls[0]![0]).toMatchObject({ serverVersion: "Neo4j/4.4.44" });
|
||||
});
|
||||
});
|
||||
@@ -17,6 +17,7 @@ const mocks = vi.hoisted(() => ({
|
||||
setErrorResult: vi.fn(),
|
||||
setTableMeta: vi.fn(),
|
||||
updateSql: vi.fn(),
|
||||
databaseInfo: undefined as { productName?: string; productVersion?: string } | undefined,
|
||||
}));
|
||||
|
||||
vi.mock("@/lib/backend/api", () => ({
|
||||
@@ -27,7 +28,7 @@ vi.mock("@/lib/backend/api", () => ({
|
||||
vi.mock("@/stores/connectionStore", () => ({
|
||||
useConnectionStore: () => ({
|
||||
activeConnectionId: "",
|
||||
getConfig: () => ({ id: "connection-1", db_type: mocks.databaseType }),
|
||||
getConfig: () => ({ id: "connection-1", db_type: mocks.databaseType, database_info: mocks.databaseInfo }),
|
||||
ensureConnected: mocks.ensureConnected,
|
||||
connectionIdentifierQuote: () => undefined,
|
||||
metadataGenerationFor: () => 0,
|
||||
@@ -108,6 +109,7 @@ describe("useNavigationTargets openTableTarget", () => {
|
||||
mocks.tabs.length = 0;
|
||||
mocks.databaseType = "postgres";
|
||||
mocks.tableOpenSortMode = "none";
|
||||
mocks.databaseInfo = undefined;
|
||||
mocks.ensureConnected.mockResolvedValue(undefined);
|
||||
mocks.buildTableSelectSql.mockImplementation(async ({ tableName }: { tableName: string }) => `SELECT * FROM ${tableName}`);
|
||||
mocks.executeTabSql.mockResolvedValue(undefined);
|
||||
@@ -130,6 +132,30 @@ describe("useNavigationTargets openTableTarget", () => {
|
||||
expect(mocks.tabs[0]?.orderByInput).toBeUndefined();
|
||||
});
|
||||
|
||||
it("forwards the connected server version to the table SQL builder (#10503)", async () => {
|
||||
mocks.databaseType = "neo4j";
|
||||
mocks.databaseInfo = { productName: "Neo4j", productVersion: "Neo4j/4.4.44" };
|
||||
|
||||
await useNavigationTargets(dialogs).openTableTarget({ connectionId: "connection-1", database: "neo4j", tableName: "users", tableType: "TABLE" });
|
||||
|
||||
expect(mocks.buildTableSelectSql).toHaveBeenCalledWith(expect.objectContaining({ serverVersion: "Neo4j/4.4.44" }));
|
||||
});
|
||||
|
||||
it("reads the server version when the SQL is built, not from the config captured before connect (#10503)", async () => {
|
||||
mocks.databaseType = "neo4j";
|
||||
mocks.databaseInfo = undefined;
|
||||
// The store swaps the config object when the probe lands, so the reference captured before
|
||||
// connect never sees the version.
|
||||
mocks.getColumns.mockImplementation(async () => {
|
||||
mocks.databaseInfo = { productName: "Neo4j", productVersion: "Neo4j/4.4.44" };
|
||||
return [column("id")];
|
||||
});
|
||||
|
||||
await useNavigationTargets(dialogs).openTableTarget({ connectionId: "connection-1", database: "neo4j", tableName: "users", tableType: "TABLE" });
|
||||
|
||||
expect(mocks.buildTableSelectSql).toHaveBeenCalledWith(expect.objectContaining({ serverVersion: "Neo4j/4.4.44" }));
|
||||
});
|
||||
|
||||
it.each(["oracle", "oceanbase-oracle"])("uses the %s physical primary index for default ordering", async (databaseType) => {
|
||||
mocks.databaseType = databaseType;
|
||||
mocks.tableOpenSortMode = "database";
|
||||
|
||||
@@ -122,6 +122,7 @@ export function useDataGridActions(activeTab: ComputedRef<QueryTab | undefined>)
|
||||
return buildTableSelectSql({
|
||||
databaseType: effectiveDbType,
|
||||
driverProfile: config?.driver_profile,
|
||||
serverVersion: config?.database_info?.productVersion,
|
||||
identifierQuote: connectionStore.connectionIdentifierQuote?.(tab.connectionId),
|
||||
database: tableMeta?.database,
|
||||
schema: tableMeta?.schema,
|
||||
|
||||
@@ -1592,6 +1592,7 @@ export function useDataGridEditor(options: UseDataGridEditorOptions) {
|
||||
if (!tableMeta.value) return null;
|
||||
return {
|
||||
databaseType: resolvedDatabaseType.value,
|
||||
serverVersion: connectionStore.getConfig(connectionId.value ?? "")?.database_info?.productVersion,
|
||||
identifierQuote: connectionStore.connectionIdentifierQuote?.(connectionId.value),
|
||||
tableMeta: tableMeta.value,
|
||||
columns: result.value.columns,
|
||||
|
||||
@@ -258,6 +258,7 @@ export function useDataGridLargeValues(options: UseDataGridLargeValuesOptions) {
|
||||
if (!visibleLargeValuePreviewActive || generation !== visibleLargeValuePreviewRequestedGeneration || options.result.value !== sourceResult) return;
|
||||
const sql = await buildTableSelectSql({
|
||||
databaseType: options.databaseType.value,
|
||||
serverVersion: options.getConnectionConfig(options.connectionId.value!)?.database_info?.productVersion,
|
||||
identifierQuote: options.connectionIdentifierQuote(options.connectionId.value),
|
||||
database: tableMeta.database,
|
||||
schema: tableMeta.schema,
|
||||
@@ -426,6 +427,7 @@ export function useDataGridLargeValues(options: UseDataGridLargeValuesOptions) {
|
||||
const selectedColumns = [...new Set([...tableMeta.primaryKeys, sourceColumn])];
|
||||
const sql = await buildTableSelectSql({
|
||||
databaseType: options.databaseType.value,
|
||||
serverVersion: options.getConnectionConfig(options.connectionId.value!)?.database_info?.productVersion,
|
||||
identifierQuote: options.connectionIdentifierQuote(options.connectionId.value),
|
||||
database: tableMeta.database,
|
||||
schema: tableMeta.schema,
|
||||
|
||||
@@ -147,6 +147,7 @@ async function openTableTarget(target: NavigationTarget, options: { tableInfoTab
|
||||
const sql = await buildTableSelectSql({
|
||||
databaseType: effectiveDbType,
|
||||
driverProfile: config.driver_profile,
|
||||
serverVersion: connectionStore.getConfig(target.connectionId)?.database_info?.productVersion,
|
||||
identifierQuote,
|
||||
schema: tableSchema,
|
||||
catalog: target.catalog,
|
||||
@@ -204,6 +205,7 @@ async function openTableTarget(target: NavigationTarget, options: { tableInfoTab
|
||||
const sql = await buildTableSelectSql({
|
||||
databaseType: effectiveDbType,
|
||||
driverProfile: config.driver_profile,
|
||||
serverVersion: connectionStore.getConfig(target.connectionId)?.database_info?.productVersion,
|
||||
identifierQuote,
|
||||
schema: tableSchema,
|
||||
catalog: target.catalog,
|
||||
@@ -255,6 +257,7 @@ async function openTableTarget(target: NavigationTarget, options: { tableInfoTab
|
||||
const emptySql = await buildTableSelectSql({
|
||||
databaseType: effectiveDbType,
|
||||
driverProfile: config.driver_profile,
|
||||
serverVersion: connectionStore.getConfig(target.connectionId)?.database_info?.productVersion,
|
||||
identifierQuote,
|
||||
schema: tableSchema,
|
||||
catalog: target.catalog,
|
||||
@@ -302,6 +305,7 @@ async function openTableTarget(target: NavigationTarget, options: { tableInfoTab
|
||||
const newSql = await buildTableSelectSql({
|
||||
databaseType: effectiveDbType,
|
||||
driverProfile: config.driver_profile,
|
||||
serverVersion: connectionStore.getConfig(target.connectionId)?.database_info?.productVersion,
|
||||
identifierQuote,
|
||||
schema: tableSchema,
|
||||
catalog: target.catalog,
|
||||
|
||||
@@ -375,6 +375,7 @@ export function useSidebarDataOpenRuntime() {
|
||||
const sql = await buildTableSelectSql({
|
||||
databaseType: effectiveDbType,
|
||||
driverProfile: config?.driver_profile,
|
||||
serverVersion: connectionStore.getConfig(node.connectionId)?.database_info?.productVersion,
|
||||
identifierQuote: connectionStore.connectionIdentifierQuote?.(node.connectionId),
|
||||
schema: tableSchema,
|
||||
database: node.database,
|
||||
|
||||
Reference in new issue
Block a user