rusackas commented on code in PR #41492:
URL: https://github.com/apache/superset/pull/41492#discussion_r3754227489
##########
superset-frontend/src/SqlLab/components/EditorWrapper/useKeywords.test.ts:
##########
@@ -210,6 +211,100 @@ test('quotes table identifiers that require quoting in
the inserted value', asyn
);
});
+test.each([
+ ['mysql', { start: '`', end: '`' }, '`COVID Vaccines`'],
+ ['mariadb', { start: '`', end: '`' }, '`COVID Vaccines`'],
+ ['mssql', { start: '[', end: ']' }, '[COVID Vaccines]'],
+ ['postgresql', { start: '"', end: '"' }, '"COVID Vaccines"'],
+])(
+ 'quotes table identifiers using the engine-provided quote characters for %s',
+ async (_dialect, identifierQuote, expectedValue) => {
+ const dbFunctionNamesApiRoute =
`glob:*/api/v1/database/${expectDbId}/function_names/`;
+ fetchMock.get(dbFunctionNamesApiRoute, fakeFunctionNamesApiResult);
+
+ const storeWithBackend = createStore(
+ {
+ ...initialState,
+ sqlLab: {
+ ...initialState.sqlLab,
+ databases: {
+ [expectDbId]: {
+ engine_information: { identifier_quote: identifierQuote },
+ },
+ },
+ },
+ },
+ reducers,
+ );
+
+ act(() => {
+ storeWithBackend.dispatch(
+ tableApiUtil.upsertQueryData(
+ 'tables',
+ { dbId: expectDbId, schema: expectSchema },
+ {
+ options: [
+ {
+ value: 'COVID Vaccines',
+ label: 'COVID Vaccines',
+ type: 'table',
+ },
+ ],
+ hasMore: false,
+ },
+ ),
+ );
+ });
+
+ const { result } = renderHook(
+ () =>
+ useKeywords({
+ queryEditorId: 'testqueryid',
+ dbId: expectDbId,
+ schema: expectSchema,
+ }),
+ {
+ wrapper: createWrapper({
+ useRedux: true,
+ store: storeWithBackend,
+ }),
+ },
+ );
+
+ await waitFor(() =>
+ expect(result.current).toContainEqual(
+ expect.objectContaining({
+ name: 'COVID Vaccines',
+ value: expectedValue,
+ meta: 'table',
+ }),
+ ),
+ );
+
+ // The caption inserted into the editor on selection is quoted with the
+ // same dialect-specific characters as `value`, not a hardcoded ANSI quote.
+ const tableKeyword = result.current.find(
+ keyword => keyword.meta === 'table' && keyword.name === 'COVID Vaccines',
+ );
+ const insertMatch = tableKeyword?.completer?.insertMatch;
Review Comment:
Went ahead and fixed this instead of punting it. `toAceKeyword` really was
dropping `completer`/`caption`, so `addTable` never fired on the shipped Ace
path. Now it carries both through when present, and the test converts through
the real function instead of fabricating what Ace would pass. Verified by
reverting locally, all five dialect cases fail without it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]