-
Notifications
You must be signed in to change notification settings - Fork 357
Description
Hi! 👋
First of all, thank you for this extension — it’s very useful.
I’ve noticed an issue with SQL formatting when using Python DB-API
drivers such as psycopg / psycopg3.
Problem
The formatter automatically rewrites DB-API pyformat placeholders:
%(end_date)sinto:
% (end_date) sThis breaks SQL execution completely, because %(param)s is a valid and
widely used placeholder format in Python database drivers
(psycopg2 / psycopg3).
This happens even when VS Code formatOnSave is disabled for SQL,
so it seems to be done internally by the Database Client formatter.
Why this matters
%(param)s is not a SQL operator — it is a parameter placeholder
defined by Python DB-API (PEP 249) and is extremely common in:
- ETL / analytics projects
- psycopg3
- SQLAlchemy Core (text queries)
- Airflow / custom SQL pipelines
Automatically inserting spaces makes valid queries unusable.
Feature request / suggestion
It would be great to have one of the following:
- An option to disable formatting of
%()spatterns - An option to disable SQL formatting on save entirely
- A PostgreSQL / DB-API–aware mode that preserves
%(param)s
Even a simple toggle like:
database-client.sqlFormatter.preservePyFormat: truewould fully solve the issue.
Temporary workaround
Right now the only workaround is to avoid %(...)s in SQL files or
disable the extension, which is unfortunate.
Thanks again for the great extension, and I hope this can be improved 🙏