Quote table names in plugin database explorer

This commit is contained in:
Tulir Asokan 2020-01-02 00:45:45 +02:00
parent 69362de854
commit 6bc6a08c83

View file

@ -90,7 +90,7 @@ class InstanceDatabase extends Component {
} }
buildSQLQuery(table = this.state.selectedTable, resetContent = true) { buildSQLQuery(table = this.state.selectedTable, resetContent = true) {
let query = `SELECT * FROM ${table}` let query = `SELECT * FROM "${table}"`
if (this.order.size > 0) { if (this.order.size > 0) {
const order = Array.from(this.order.entries()).reverse() const order = Array.from(this.order.entries()).reverse()
@ -198,10 +198,10 @@ class InstanceDatabase extends Component {
const val = values[index] const val = values[index]
condition.push(`${key}='${this.sqlEscape(val.toString())}'`) condition.push(`${key}='${this.sqlEscape(val.toString())}'`)
} }
const query = `DELETE FROM ${this.state.selectedTable} WHERE ${condition.join(" AND ")}` const query = `DELETE FROM "${this.state.selectedTable}" WHERE ${condition.join(" AND ")}`
const res = await api.queryInstanceDatabase(this.props.instanceID, query) const res = await api.queryInstanceDatabase(this.props.instanceID, query)
this.setState({ this.setState({
prevQuery: `DELETE FROM ${this.state.selectedTable} ...`, prevQuery: `DELETE FROM "${this.state.selectedTable}" ...`,
rowCount: res.rowcount, rowCount: res.rowcount,
}) })
await this.reloadContent(false) await this.reloadContent(false)