grafana / grafana/google-bigquery-datasource
Incorrect interpolation of single quote for multi-value variable
- Dominant language
- TypeScript
- Stars
- 40
- Forks
- 24
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 8
Description
### Summary
The plugin's automatic quoting for multi-value and "Include All" variables uses the wrong escape sequence for embedded single quotes. It doubles the quote (`''`), which is ANSI SQL syntax. BigQuery does not support this — [instead it supports a backslash escape](https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/lexical#quoted_literals) (`\'`).
### Steps to reproduce
1. Create a multi-value (or Include All) query variable whose options include a value containing a single quote character. (eg. `O'Reilly`)
2. Reference it in a query: `AND x IN (${my_var})`.
3. Select that value (or select "All").
### Expected
The plugin escapes the apostrophe using BigQuery's syntax:
`delivery_provider IN ('O\'Reilly')`
### Actual
The plugin doubles the quote instead, producing invalid BigQuery syntax:
`delivery_provider IN ('O''Reilly')`
which BigQuery parses as two adjacent string literals and rejects:
Error 400: Syntax error: concatenated string literals must be separated by whitespace or comments at [line:col], invalidQuery
### Environment
- grafana-bigquery-datasource version: 3.1.5
- Grafana version: 11.6.1
Contributor guide
Research direction
Start by locating the plugin's automatic quoting and interpolation logic for multi-value and “Include All” variables. Reproduce the issue with a value such as O'Reilly in a BigQuery query, then verify that the generated IN expression uses BigQuery's backslash escape and no longer produces the reported syntax error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- google-cloud, typescript
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100