Skip to content

Commit

Permalink
Add FAQ entry about SQL templating
Browse files Browse the repository at this point in the history
  • Loading branch information
nene committed Nov 9, 2023
1 parent 5085e78 commit f907e99
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,27 @@ extension is no more maintained by its author.
Please use the official [SQL Formatter VSCode](https://marketplace.visualstudio.com/items?itemName=ReneSaarsoo.sql-formatter-vsc)
extension to get the latest fixes from SQL Formatter library.

### My SQL contains templating syntax which SQL Formatter fails to parse

For example, you might have an SQL like:

```sql
SELECT {col1}, {col2} FROM {tablename}
```

While templating is not directly supported by SQL Formatter, the workaround
is to use [paramTypes](docs/paramTypes.md) config option to treat these
occurances of templating constructs as prepared-statement parameter-placeholders:

```js
format('SELECT {col1}, {col2} FROM {tablename};', {
paramTypes: { custom: [{ regex: String.raw`\{\w+\}` }] },
});
```

This won't work for all possible templating constructs,
but should solve the most common use cases.

## The future

The development of this formatter is currently in maintenance mode.
Expand Down

0 comments on commit f907e99

Please sign in to comment.