You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by el...@apache.org on 2021/09/21 16:41:27 UTC
[superset] branch master updated: only fetch db function when db
exists in sql lab (#16754)
This is an automated email from the ASF dual-hosted git repository.
elizabeth pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new d375538 only fetch db function when db exists in sql lab (#16754)
d375538 is described below
commit d37553867157464ffb36b5cdeaf9e0cf7a2546a9
Author: Elizabeth Thompson <es...@gmail.com>
AuthorDate: Tue Sep 21 09:40:02 2021 -0700
only fetch db function when db exists in sql lab (#16754)
---
.../src/SqlLab/components/AceEditorWrapper.tsx | 17 ++++++++++-------
.../src/SqlLab/components/ShareSqlLabQuery.tsx | 10 ++--------
superset-frontend/src/SqlLab/types.ts | 13 +++++++++++++
3 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/superset-frontend/src/SqlLab/components/AceEditorWrapper.tsx b/superset-frontend/src/SqlLab/components/AceEditorWrapper.tsx
index 3c33f4c..825d30c 100644
--- a/superset-frontend/src/SqlLab/components/AceEditorWrapper.tsx
+++ b/superset-frontend/src/SqlLab/components/AceEditorWrapper.tsx
@@ -30,6 +30,7 @@ import {
AceCompleterKeyword,
FullSQLEditor as AceEditor,
} from 'src/components/AsyncAceEditor';
+import { QueryEditor } from '../types';
type HotKey = {
key: string;
@@ -51,7 +52,7 @@ interface Props {
tables: any[];
functionNames: string[];
extendedTables: Array<{ name: string; columns: any[] }>;
- queryEditor: any;
+ queryEditor: QueryEditor;
height: string;
hotkeys: HotKey[];
onChange: (sql: string) => void;
@@ -86,10 +87,12 @@ class AceEditorWrapper extends React.PureComponent<Props, State> {
componentDidMount() {
// Making sure no text is selected from previous mount
this.props.actions.queryEditorSetSelectedText(this.props.queryEditor, null);
- this.props.actions.queryEditorSetFunctionNames(
- this.props.queryEditor,
- this.props.queryEditor.dbId,
- );
+ if (this.props.queryEditor.dbId) {
+ this.props.actions.queryEditorSetFunctionNames(
+ this.props.queryEditor,
+ this.props.queryEditor.dbId,
+ );
+ }
this.setAutoCompleter(this.props);
}
@@ -228,8 +231,8 @@ class AceEditorWrapper extends React.PureComponent<Props, State> {
getAceAnnotations() {
const { validationResult } = this.props.queryEditor;
- const resultIsReady = validationResult && validationResult.completed;
- if (resultIsReady && validationResult.errors.length > 0) {
+ const resultIsReady = validationResult?.completed;
+ if (resultIsReady && validationResult?.errors?.length) {
const errors = validationResult.errors.map((err: any) => ({
type: 'error',
row: err.line_number - 1,
diff --git a/superset-frontend/src/SqlLab/components/ShareSqlLabQuery.tsx b/superset-frontend/src/SqlLab/components/ShareSqlLabQuery.tsx
index 5f6c89c..66d6902 100644
--- a/superset-frontend/src/SqlLab/components/ShareSqlLabQuery.tsx
+++ b/superset-frontend/src/SqlLab/components/ShareSqlLabQuery.tsx
@@ -26,16 +26,10 @@ import CopyToClipboard from 'src/components/CopyToClipboard';
import { storeQuery } from 'src/utils/common';
import { getClientErrorObject } from 'src/utils/getClientErrorObject';
import { FeatureFlag, isFeatureEnabled } from '../../featureFlags';
+import { QueryEditor } from '../types';
interface ShareSqlLabQueryPropTypes {
- queryEditor: {
- dbId: number;
- title: string;
- schema: string;
- autorun: boolean;
- sql: string;
- remoteId: number | null;
- };
+ queryEditor: QueryEditor;
addDangerToast: (msg: string) => void;
}
diff --git a/superset-frontend/src/SqlLab/types.ts b/superset-frontend/src/SqlLab/types.ts
index a50d664..1308f58 100644
--- a/superset-frontend/src/SqlLab/types.ts
+++ b/superset-frontend/src/SqlLab/types.ts
@@ -69,3 +69,16 @@ export type Query = {
queryLimit: number;
limitingFactor: string;
};
+
+export interface QueryEditor {
+ dbId?: number;
+ title: string;
+ schema: string;
+ autorun: boolean;
+ sql: string;
+ remoteId: number | null;
+ validationResult?: {
+ completed: boolean;
+ errors: SupersetError[];
+ };
+}