Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #119 from influxdata/fix/get-tables
Browse files Browse the repository at this point in the history
fix: get tables for sqllite client
  • Loading branch information
helenosheaa authored Mar 20, 2023
2 parents 0fa82cc + 5f6fc70 commit 1c9e142
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flightsql-datasource",
"version": "0.1.6",
"version": "0.1.7",
"description": "",
"scripts": {
"build": "webpack -c ./.config/webpack/webpack.config.ts --env production",
Expand Down
4 changes: 3 additions & 1 deletion pkg/flightsql/flightsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ func NewDatasource(settings backend.DataSourceInstanceSettings) (instancemgmt.In
if _, ok := md[k]; ok {
return nil, fmt.Errorf("metadata: duplicate key: %s", k)
}
md.Set(k, v)
if k != "" {
md.Set(k, v)
}
}
}

Expand Down
13 changes: 10 additions & 3 deletions pkg/flightsql/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,16 @@ func (d *FlightSQLDatasource) getTables(w http.ResponseWriter, r *http.Request)
ctx, cancel := context.WithTimeout(r.Context(), 30*time.Second)
defer cancel()
ctx = metadata.NewOutgoingContext(ctx, d.md)
info, err := d.client.GetTables(ctx, &flightsql.GetTablesOpts{
TableTypes: []string{"BASE TABLE"},
})
bucketMetaData := d.md.Get("bucket-name")

opts := &flightsql.GetTablesOpts{}

if len(bucketMetaData) > 0 {
opts = &flightsql.GetTablesOpts{
TableTypes: []string{"BASE TABLE"},
}
}
info, err := d.client.GetTables(ctx, opts)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
Expand Down
10 changes: 3 additions & 7 deletions src/components/ConfigEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,13 @@ export function ConfigEditor(props: DataSourcePluginOptionsEditorProps<FlightSQL
}, [selectedAuthType])

useEffect(() => {
const {onOptionsChange, options} = props
let mapData
let jsonData
if (metaDataArr[0]?.key !== '') {
mapData = metaDataArr?.map((m: any) => ({[m.key]: m.value}))
jsonData = {
const {onOptionsChange, options} = props
const mapData = metaDataArr?.map((m: any) => ({[m.key]: m.value}))
const jsonData = {
...options.jsonData,
metadata: mapData,
}
onOptionsChange({...options, jsonData})
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [metaDataArr])

Expand Down
26 changes: 21 additions & 5 deletions src/components/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,27 @@ export const onPasswordChange = (event: any, options: any, onOptionsChange: any)
}

export const onAuthTypeChange = (selectedAuthType: any, options: any, onOptionsChange: any) => {
const jsonData = {
...options.jsonData,
selectedAuthType: selectedAuthType?.label,
}
onOptionsChange({...options, jsonData})
const notTokenType = selectedAuthType?.label !== "token"
const notPassType = selectedAuthType?.label !== "username/password"

onOptionsChange({
...options,
jsonData: {
...options.jsonData,
selectedAuthType: selectedAuthType?.label,
username: notPassType && '',
},
secureJsonFields: {
...options.secureJsonFields,
token: notTokenType && false,
password: notPassType && false,
},
secureJsonData: {
...options.secureJsonData,
token: notTokenType && '',
password: notPassType && '',
},
})
}

export const getSqlCompletionProvider: (args: any) => LanguageCompletionProvider =
Expand Down

0 comments on commit 1c9e142

Please sign in to comment.