feat: add separate endpoint to fetch function names for autocomplete (#12840)

* WIP

* Add unit test for API

* Add spec

* Fix unit test

* Fix unit test

* Fix test

* Fix test

* Add period to error message
This commit is contained in:
Beto Dealmeida
2021-02-02 18:01:01 -08:00
committed by GitHub
parent 8553543ab0
commit ab3f4bd94b
10 changed files with 113 additions and 11 deletions

View File

@@ -41,6 +41,7 @@ type HotKey = {
interface Props {
actions: {
queryEditorSetSelectedText: (edit: any, text: null | string) => void;
queryEditorSetFunctionNames: (queryEditor: object, dbId: number) => void;
addTable: (queryEditor: any, value: any, schema: any) => void;
};
autocomplete: boolean;
@@ -85,6 +86,10 @@ 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,
);
this.setAutoCompleter(this.props);
}

View File

@@ -474,9 +474,7 @@ class SqlEditor extends React.PureComponent {
sql={this.props.queryEditor.sql}
schemas={this.props.queryEditor.schemaOptions}
tables={this.props.queryEditor.tableOptions}
functionNames={
this.props.database ? this.props.database.function_names : []
}
functionNames={this.props.queryEditor.functionNames}
extendedTables={this.props.tables}
height={`${aceEditorHeight}px`}
hotkeys={hotkeys}

View File

@@ -80,6 +80,10 @@ export default class SqlEditorLeftBar extends React.PureComponent {
onDbChange(db) {
this.props.actions.queryEditorSetDb(this.props.queryEditor, db.id);
this.props.actions.queryEditorSetFunctionNames(
this.props.queryEditor,
db.id,
);
}
onTableChange(tableName, schemaName) {