Git Product home page Git Product logo

Comments (6)

nene avatar nene commented on July 22, 2024 2

This is now configurable through the lineWidth option. Though for now this configuration has all the problems listed above.

from sql-formatter.

nene avatar nene commented on July 22, 2024 1

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.

ukupat avatar ukupat commented on July 22, 2024

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.

jonahx avatar jonahx commented on July 22, 2024

@nene

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.

nene avatar nene commented on July 22, 2024

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.

jonahx avatar jonahx commented on July 22, 2024

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....

  1. Need pg and tsql support
  2. 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 through sql-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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.