Rule Suggestion: disallow expression on same line as SELECT (if num_expressions>1)
See original GitHub issueGiven this example:
SELECT Md5(-1) AS gl_account_key,
0 AS gl_account_number,
'Unknown' AS gl_account_name,
'Unknown' AS gl_major_category,
'Unknown' AS reporting_major_category
SQLFluff fixes as:
SELECT Md5(-1) AS gl_account_key,
0 AS gl_account_number,
'Unknown' AS gl_account_name,
'Unknown' AS gl_major_category,
'Unknown' AS reporting_major_category
Whereas I think the best practice should be:
SELECT
Md5(-1) AS gl_account_key,
0 AS gl_account_number,
'Unknown' AS gl_account_name,
'Unknown' AS gl_major_category,
'Unknown' AS reporting_major_category
In other words: If the number of expressions is greater than one, none of them should share a line with SELECT and all should be indented the standard 4 characters.
Thoughts? Agree/disagree?
I qualify based on the number of expressions because a case can be made that this:
SELECT
mycol
FROM mytable
…is less desirable/readable than:
SELECT mycol
FROM mytable
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Select form and its label in same line in bootstrap3
Here is one way : Bootply : http://www.bootply.com/YzaMGyRq99. CSS : select.form-control{display:inline-block}. HTML :
Read more >How To Prevent Line Breaks Using CSS - DigitalOcean
Text wrapping can also prevent horizontal scrolling. But there are times when you want blocks of text to stay on the same line,...
Read more >CSS text-align-last property - W3Schools
Notice that the text-align-last property sets the alignment for all last lines within the selected element. So, if you have a <div> with...
Read more >How to Prevent Two or More Words from Being Split into ...
How to selectively disable word wrapping on a web page so that two or more words are not split and placed on separate...
Read more >user-select - CSS: Cascading Style Sheets - MDN Web Docs
If a double-click or context-click occurred in sub-elements, the highest ancestor with this value will be selected. contain. Enables selection ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@pwildenhain - Indeed. Thank you for linking the two. Where the two differ, as far as I can tell, is just the comment from Alan on #352 related to multiple first line columns being okay, whereas here I’ve suggested only allowing when a single expression is named.
Taking the safe assumption that line length is already enforced, I think I’m okay with all of these:
Whereas these would be anti-patterns:
I’m open to this as a rule, with a few potential exceptions.
SELECT 1 FROM blah
without an alias for the column.e.g.
GOOD (Scalar query)
(Hanging indent, i.e. a & c have the same indent. There’s some logic in L003 to work this out that should probably be more generic.)
BAD
… should fix to …