Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-row-details-id-where.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperdx/app': patch
---

Fix expanding a row on tables with a string `id` column: row details now keep the internal WHERE-clause id instead of being overwritten by the raw column value (#3370)
2 changes: 1 addition & 1 deletion packages/app/src/components/DBRowTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1363,10 +1363,10 @@ export const RawLogTable = memo(
canOpenSidePanel={canOpenSidePanel}
>
{renderRowDetails?.({
...row.original,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — No regression test pins that id/aliasWith override a same-named column in row details

Add a case to the existing inline-expand suite in packages/app/src/components/__tests__/DBRowTable.test.tsx (baseProps ~line 316). Use rows: [{ id: 'a5c1334f-...', col1: 'v' }] and a jest.fn() renderRowDetails, expand the row, then assert it was called with expect.objectContaining({ id: ROW_ID }). Without it, moving the spread back after id would bring #3370 back and every test would still pass.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 minor — No regression test for the id-column overwrite this PR fixes

The RawLogTable inline-expand tests in packages/app/src/components/__tests__/DBRowTable.test.tsx (baseProps around line 316) already set up the table for this. Add a case with rows: [{ id: 'a5c1334f-...', col1: 'value1' }] and a jest.fn() renderRowDetails. Expand the row and assert the mock was called with expect.objectContaining({ id: ROW_ID, aliasWith: [] }). Without that test, nothing stops someone from moving the spread back after id later.

Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond

id: rowId,
aliasWith:
row.original[INTERNAL_ROW_FIELDS.ALIAS_WITH],
Comment on lines +1366 to 1369

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Spread order has no test

This fix changes which id and aliasWith reach renderRowDetails, but adds no test. Existing expansion tests use rows without an id column, and their details callback ignores its argument, so they would pass with the old bug.

AGENTS.md requires tests alongside the implementation. Before merging, add a test that expands a row with a raw string id and checks that renderRowDetails receives the generated WHERE clause as id. Also check that computed aliasWith wins over a matching raw column.

Context Used: AGENTS.md (source)

Fix in Claude Code Fix in Conductor Fix in Cursor Fix in Codex

...row.original,
})}
</ExpandedLogRow>
)}
Expand Down
37 changes: 36 additions & 1 deletion packages/app/src/components/__tests__/DBRowTable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
useConfigWithAdditionalSelect,
} from '@/components/DBRowTable';
import * as useChartConfigModule from '@/hooks/useChartConfig';
import { RowWhereResult } from '@/hooks/useRowWhere';
import { RowWhereResult, WithClause } from '@/hooks/useRowWhere';
import { RowClickAction, UserPreferences } from '@/useUserPreferences';

const mockSetQueryState = jest.fn();
Expand Down Expand Up @@ -392,6 +392,41 @@ describe('RawLogTable', () => {
expect(mockSetQueryState).toHaveBeenCalledWith('rowWhere', ROW_ID);
});

// A table with its own `id` column must not overwrite the WHERE clause the
// expanded row queries with (#3370).
it('passes the row where clause to row details when the row has an id column', async () => {
const aliasWith: WithClause[] = [
{
name: 'body',
sql: { sql: 'Body', params: {} },
isSubquery: false,
},
];
const renderRowDetails = jest.fn(() => <div>row details</div>);

renderTable(
<RawLogTable
{...baseProps}
rows={[
{ col1: 'value1', id: 'a5c1334f-9b43-44db-abc3-3412220272dd.0.0' },
]}
generateRowId={() => ({ where: ROW_ID, aliasWith })}
renderRowDetails={renderRowDetails}
onRowDetailsClick={() => {}}
/>,
'expand',
);

await userEvent.click(
await screen.findByRole('button', { name: 'Expand log row' }),
);

await screen.findByTestId(`expanded-row-${ROW_ID}`);
expect(renderRowDetails).toHaveBeenLastCalledWith(
expect.objectContaining({ id: ROW_ID, aliasWith, col1: 'value1' }),
);
});

it('collapses an expanded row when its body is clicked again', async () => {
renderTable(
<RawLogTable {...baseProps} onRowDetailsClick={() => {}} />,
Expand Down
Loading