Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to pass args to driver query method #20

Closed
sunker opened this issue Jun 30, 2021 · 1 comment · Fixed by #30
Closed

Make it possible to pass args to driver query method #20

sunker opened this issue Jun 30, 2021 · 1 comment · Fixed by #30
Labels
enhancement New feature or request

Comments

@sunker
Copy link
Collaborator

sunker commented Jun 30, 2021

Some data sources plugin, such as the one for Athena, will need to be able to switch database inside the query editor without having to change the connection in the config editor. The query method in the go sql package takes a variadic function parameter for args, so we should be able to use that to pass additional arguments to the driver.

Unfortunately, the args might differ from plugin to plugin, making it hard to provide proper typings for this. For that reason, I think the Query type needs to take the args as json. Something like this:

type Query struct {
	RawSQL string            `json:"rawSql"`
	Format FormatQueryOption `json:"format"`
	Args   json.RawMessage 	 `json:args`
...
}
@andresmgot
Copy link
Collaborator

The query method in the go sql package takes a variadic function parameter for args, so we should be able to use that to pass additional arguments to the driver.

@sunker I am taking a look to this and I think we should not use that args parameter to do this. These arguments are SQL arguments, the ones used to run the query (e.g. "select foo from $1", arg1") . The sql package is reading those. We would need those parameter to pass arguments to the SQL query (although that's not supported).

In any case, we can still use this package Query to add some args so the targeting datasource can act on it. I will give that a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants