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 #124 from influxdata/fix/builder-view-populate
Browse files Browse the repository at this point in the history
fix: remove table quotes to do table lookup
  • Loading branch information
helenosheaa authored Apr 3, 2023
2 parents b8bfba5 + f38f06a commit 25bb55f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 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.8",
"version": "0.1.9",
"description": "",
"scripts": {
"build": "webpack -c ./.config/webpack/webpack.config.ts --env production",
Expand Down
6 changes: 4 additions & 2 deletions src/components/BuilderView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
formatWheres,
formatCreateLabel,
prefixDB,
removeQuotes,
} from './utils'
import {SelectColumn} from './SelectColumn'
import {WhereExp} from './WhereExp'
Expand Down Expand Up @@ -114,10 +115,11 @@ export function BuilderView({query, datasource, onChange, fromRawSql}: any) {

useEffect(() => {
if (!fromRawSql && tables) {
const tableExists = tables?.find((t: any) => t.label === query.table)
const unquotedTable = removeQuotes(query?.table)
const tableExists = tables?.find((t: any) => t.label === unquotedTable)
if (tableExists) {
if (query.table) {
setTable({value: query.table, label: query.table})
setTable({value: unquotedTable, label: unquotedTable})
}
if (query.columns) {
setColumnValues(query.columns)
Expand Down
4 changes: 4 additions & 0 deletions src/components/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,7 @@ export const onResetPassword = (options: any, onOptionsChange: any) => {
},
})
}

export const removeQuotes = (str: string) => {
return str?.replace(/['"]+/g, '')
}

0 comments on commit 25bb55f

Please sign in to comment.