Comments (6)
This is now configurable through the lineWidth
option. Though for now this configuration has all the problems listed above.
from sql-formatter.
The only other feasible option that I know of is SQLFluff. But that one is really primarily a linter and not really that great of an option for completely reformatting SQL code. Though it does have a max_line_length option and it's auto-fixable.
I'm planning to add Postgres support, but that will take time as Postgres is kinda big amongst SQL dialects. Transact-SQL is likely even more work as there are actually many dialects under this label and I find the syntax diagrams in Microsoft docs to be among the more confusing ones. However, currently Postgres support is definitely the most requested feature, so there's hope.
from sql-formatter.
We know that we have the same issue jdorn/sql-formatter#59.
I was thinking about keeping AND
and OR
on the same line when the line is smaller than maxLineLength
. This could solve that issue. What do you think @nene?
from sql-formatter.
Quick question: I was trying to specify a global line length limit (similar to prettier's printWidth
) and tried the lineWidth
option, but it didn't work. Based on your comment that it "has all the problems listed above", I am assuming this is simply not supported... is this correct? Thanks!
from sql-formatter.
This option has been renamed to expressionWidth
, but it's behavior is far from intuitive.
Perhaps you're interested in trying out a new SQL formatting tool that I've written, which does support the printWidth
option as it's implemented as a Prettier plugin and uses the same layout algorithm as Prettier.
from sql-formatter.
Thanks for the reply.
Perhaps you're interested in trying out a new SQL formatting tool that I've written
In theory yes, but I have a couple of requirements that brought me to the cmdline tool here....
- Need pg and tsql support
- We have a lot of SQL that exists within template literals in JS files. So with the command-line version, I can use a VS Code (or vim, etc) plugins to highlight lines of code inside template literals, pre-process them (eg, to replace interpolated
${vars}
), run throughsql-formatter
, post-process, then replace the original text with formatted text.
2 is working great, except that there is no way to tell sql-formatter
to respect the projects overall prettier printWidth
, which would be ideal. I am open to other solutions if you know of any.
from sql-formatter.
Related Issues (20)
- Feature Request: Support TiDB syntax
- Error thrown parsing fairly long (but valid) postgresql statement HOT 3
- [FORMATTING] Column named `text` is converted to upper case HOT 1
- Feature Request: Databricks SQL Support HOT 2
- [VS Code] Support for oracle_sql language files HOT 3
- mysql: create procedure LOOP bug HOT 1
- Feature Request: Support for Duckdb HOT 4
- Configuration in Microsoft Visual Code HOT 1
- Table name or alias "call" misinterpreted by formatter HOT 1
- [FORMATTING] psycopg2 params broken up by formatter HOT 2
- [FORMATTING] Formatter inserts space in between `^@` operator, making the SQL invalid HOT 6
- [FORMATTING] Unable to parse Hive syntax: STRUCT<x: INT64, y:STRING> HOT 3
- Canot format document when '#' character is Found HOT 1
- Snowflake Unable to format SQL: Error: Parse error: Unexpected "@test;" at line 7 column 6 HOT 2
- Formatting Error with Temporary Functions HOT 2
- [FORMATTING] column name "match" is converted to uppercase. HOT 3
- [FORMATTING] Oracle pl/sql, assignment in case block HOT 1
- [FORMATTING] array type HOT 1
- [FORMATTING] Issue Title Here HOT 1
- [FORMATTING] Formatter doesn't like the ~ in SQL statement HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sql-formatter.