webyog / sqlyog-community

Webyog provides monitoring and management tools for open source relational databases. We develop easy-to-use MySQL client tools for performance tuning and database management. Webyog's solutions include SQL Diagnostic Manager for MySQL performance optimization and SQLyog for MySQL administration. More than 35,000 companies (including Amazon, IBM, Salesforce, AT&T, eBay, and GE) and 2.5 million users rely on Webyog's solutions to provide valuable insights into their databases. Webyog is an Idera, Inc. company.
https://webyog.com/
GNU General Public License v2.0
2.2k stars 324 forks source link

SQL formatter and WIndows functions #2160

Open peterwy opened 6 years ago

peterwy commented 6 years ago

The formatter should indent 'inner SELECTs' like it does with subqueries. Se below:

-- using Window Functions. This is after formatting WITH recentorders AS (SELECT -- this should be indented FROM ordertable ORDER BY order_id DESC LIMIT 100) -- should be last indented line SELECT
FROM recentorders;

-- compare a subquery after formatting SELECT FROM (SELECT -- compare: this is indented FROM ordertable DESC LIMIT 100);

peterwy commented 6 years ago

-- using Window functions. This is after formatting WITH recentorders AS (SELECT -- this should be indented * FROM ordertable ORDER BYorder_id` DESC LIMIT 100) -- should be last indented line SELECT
* FROM recentorders;

-- compare a subquery after formatting SELECT FROM (SELECT -- compare: this is indented FROM ordertable DESC LIMIT 100);`

peterwy commented 6 years ago

Please ignore the last comment. HTML formatting destroys the point.

The 2 queries to compare in formatter are WITH recentorders AS (SELECT FROM ordertable ORDER BY order_id DESC LIMIT 100) SELECT FROM recentorders; SELECT FROM (SELECT FROM ordertable DESC LIMIT 100);

peterwy commented 6 years ago

"Common Table Expressions" require a similar check with the formatter, BTW.