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
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,29 @@ test('uses exploreBackend from Redux state when available', async () => {
expect(formatCallBody.engine).toBe('postgresql');
expect(fetchMock.calls(datasetApiEndpoint)).toHaveLength(0);
});

test('sends engine as string (not object) when fetched from dataset API', async () => {
const stateWithoutBackend = {
...mockState(),
explore: undefined,
};

setup(mockProps, stateWithoutBackend);

await waitFor(() => {
expect(fetchMock.calls(datasetApiEndpoint)).toHaveLength(1);
});

await waitFor(() => {
expect(fetchMock.calls(formatSqlEndpoint)).toHaveLength(1);
});

const formatCallBody = JSON.parse(
fetchMock.lastCall(formatSqlEndpoint)?.[1]?.body as string,
);

expect(formatCallBody).toEqual({
sql: mockProps.sql,
engine: 'sqlite',
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ const ViewQuery: FC<ViewQueryProps> = props => {
const response = await SupersetClient.get({
endpoint: `/api/v1/dataset/${datasetId}?q=${queryParams}`,
});
backend = response.json.result.database;
const { backend: datasetBackend } = response.json.result.database;
backend = datasetBackend;
}

// Format the SQL query
Expand Down
Loading