mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
SQL Expressions: Simplify where code is being stubbed out (#96227)
* Rename from DuckDB * Remove unused function
This commit is contained in:
parent
30bbcf8200
commit
1915efbc95
@ -9,10 +9,6 @@ import (
|
|||||||
type DB struct {
|
type DB struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *DB) TablesList(rawSQL string) ([]string, error) {
|
|
||||||
return nil, errors.New("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (db *DB) RunCommands(commands []string) (string, error) {
|
func (db *DB) RunCommands(commands []string) (string, error) {
|
||||||
return "", errors.New("not implemented")
|
return "", errors.New("not implemented")
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,10 @@ var logger = log.New("sql_expr")
|
|||||||
|
|
||||||
// TablesList returns a list of tables for the sql statement
|
// TablesList returns a list of tables for the sql statement
|
||||||
func TablesList(rawSQL string) ([]string, error) {
|
func TablesList(rawSQL string) ([]string, error) {
|
||||||
duckDB := NewInMemoryDB()
|
db := NewInMemoryDB()
|
||||||
rawSQL = strings.Replace(rawSQL, "'", "''", -1)
|
rawSQL = strings.Replace(rawSQL, "'", "''", -1)
|
||||||
cmd := fmt.Sprintf("SELECT json_serialize_sql('%s')", rawSQL)
|
cmd := fmt.Sprintf("SELECT json_serialize_sql('%s')", rawSQL)
|
||||||
ret, err := duckDB.RunCommands([]string{cmd})
|
ret, err := db.RunCommands([]string{cmd})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("error serializing sql", "error", err.Error(), "sql", rawSQL, "cmd", cmd)
|
logger.Error("error serializing sql", "error", err.Error(), "sql", rawSQL, "cmd", cmd)
|
||||||
return nil, fmt.Errorf("error serializing sql: %s", err.Error())
|
return nil, fmt.Errorf("error serializing sql: %s", err.Error())
|
||||||
|
Loading…
Reference in New Issue
Block a user