Giter Club home page Giter Club logo

sql_formatter's People

Contributors

dependabot[bot] avatar dougthor42 avatar pablormira avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

sql_formatter's Issues

Format case when properly in SELECT statement

Currently, case when will be formatted without breaklines like

SELECT field1,
       case when field2 < 1 then 1 when field2 >=1 and field2 < 5 then 2 else 3 end as field2_cat
... 

and I would like to have some indentation like

SELECT field1,
       case when field2 < 1 then 1
            when field2 >=1 and field2 < 5 then 2 
            else 3 end as field2_cat
... 

Release v0.1.0

Release first version of the package and publish to pipy and anaconda

[BUG] PARTITION BY not properly formatted

Describe the bug

There is no formatting for PARTITION BY clausels, e.g.

SELECT asdf,
       row_number() OVER (PARTITI
       ON BY qwer
ORDER BY asdf) 

The newline for ON in PARITITION is rather a general problem as in #26

Expected behavior

SELECT asdf,
       row_number() OVER (PARTITION BY qwer
                          ORDER BY asdf) 

[CI] via regex fails sometimes

Specially something like

select asdf, qwer
/* bla bla */
/* bla bla 2 */
asdf2
from table1

will be marked as

select asdf, qwer
[CS]/* bla bla */[C]  [CI] /* bla bla 2 */[C]
asdf2
from table1

This is wrong: [CI] is only for newlines within multiline comments

[BUG] SELECT adds newline for function arguments

Describe the bug

sql-formatter sql_file.sql separates function arguments in SELECT as if they were normal fields, e.g.

SELECT asdf,
       substr(asdf,
       3,
       1) as substr_asdf  

Expected behavior

SELECT asdf,
       substr(asdf, 3, 1) as substr_asdf  

[BUG] ON formatting does not work properly

Describe the bug

ON formatting function formats also words containing "on", like function. Consider the following query:

SELECT asdf,
               my_function
FROM   ...

The formatter then does

SELECT asdf,
               my_functi
ON
FROM   ...

Expected behavior

SELECT asdf,
               my_function
FROM    ...

No formatting for ORDER BY

Describe the bug

ORDER BY is not being formatted

Expected behavior

ORDER BY should be formatted like GROUP BY

[FEA] Reformat case when if line too long

Related to #52

E.g.

select asdf,
       case when asdf >= 1 and asdf <= 10 and substr(qwer, 1, 2) = 'abc' and substr(qwer, 3, 2) = 'qwerty' then 1
            else 0 end as case_field,
       asdf2
from table1

should be formatted as

select asdf,
       case when asdf >= 1 and 
                 asdf <= 10 and 
                 substr(qwer, 1, 2) = 'abc' and 
                 substr(qwer, 3, 2) = 'qwerty' then 1
            else 0 end as case_field,
       asdf2
from table1

CREATE validation fails

Something like

CREATE TASK bla bla
CREATE TABLE my_table AS

should not return a warning.

Only CREATE TABLE / VIEW twice should return a warning

case when wrongly formatted if comment after first condition

something like

select asdf,
case when asdf = 1 and -- some comment
asdf != 2 then 1 else 0 end as some_field
from table1

would be formatted like

select asdf,
       case when asdf = 1 and -- some comment
            asdf != 2 then 1 else 0 end as some_field
from table1

and not better like

select asdf,
       case when asdf = 1 and -- some comment
                 asdf != 2 then 1 else 0 end as some_field
from table1

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.