We use dbt, and our models are .sql files with Jinja templating. In the Bitbucket Cloud source view and in PR diffs, a single apostrophe inside a Jinja comment ({# ... #}) breaks highlighting for the rest of the file. The highlighter treats the apostrophe as the start of a SQL string, so everything after it is inverted: code is coloured as strings and strings as code.
Minimal example:
sql
{#
Selects the run's hours.
#}
select
id,
'{{ var("version") }}' as version
from {{ ref('my_model') }
As far as we can tell, the file is highlighted as plain SQL, which has no concept of {# #} comments. Jinja delimiters ({{ }}, {% %}, {# #}) don’t occur in standard SQL, and editors with a dbt/Jinja-SQL language mode highlight this file correctly. This has come up before for other comment styles (this 2024 thread), and BCLOUD-19693 notes that the file view relies on Monaco’s language support.
Our questions:
- Is there a way to override the highlighting language for a file, path or repository, for example via
.gitattributes or a repository setting? - Are there plans to detect Jinja-templated SQL, such as dbt projects identified by
dbt_project.yml, and highlight it accordingly? - If neither exists, is there an existing BCLOUD suggestion we should vote on, or should we raise a new one?
Our current workaround is to avoid apostrophes in Jinja comments. That’s easy to forget, though, and dbt is common enough that native support would help a lot of teams.