Comments (6)
I agree that the formatting of conditions with parenthesis is not optimal. The change is for sure not simple.
from plsql-formatter-settings.
I think you are master of this code - If you think that required workload is not appropriate to required benefit, it is correct situation and we can close this issue.
from plsql-formatter-settings.
It's a valid issue. Therefore I like to keep it open for the time being.
I need a bit more time to think about it. In the end the formatting rules should be consistent. Currently the original SQLDev right-aligning strategy for AND
and OR
is consistent. It looks strange with parenthesis or even when mixing AND
and OR
conditions without parenthesis. But it is okay for a series of AND
-only or OR
-only conditions.
from plsql-formatter-settings.
Here's another way to format it which has some consistent logic (treating AND
and OR
with parenthesis like functions) but looks strange.
SELECT *
FROM dba_tables
WHERE (
owner = 'SYSTEM'
AND (
table_name = 'REDO_DB'
OR table_name = 'REDO_LOG'
)
) OR (
owner = 'SYS'
AND (
table_name = 'ALERT_QT'
OR table_name = 'ALL_UNIFIED_AUDIT_ACTIONS'
)
);
When formatting the code by hand the result would be much more compact. Something like this:
SELECT *
FROM dba_tables
WHERE (owner = 'SYSTEM' AND (table_name = 'REDO_DB' OR table_name = 'REDO_LOG'))
OR (owner = 'SYS' AND (table_name = 'ALERT_QT' OR table_name = 'ALL_UNIFIED_AUDIT_ACTIONS'));
So, this is also related to line size and line breaks as we discussed it in issue #33. In this case it's not arguments it's the number of sub-conditions. As soon as we are going to add line breaks to conditions the things become a bit complicated.
from plsql-formatter-settings.
It looks pretty good.
I think there is a similar issue in pl/SQL:
begin
if ( ( 1 = 2 ) or ( (
2 = 2 and 3 = 3
) or ( 4 = 5 ) ) ) then
dbms_output.put_line('Yes');
end if;
end;
from plsql-formatter-settings.
Formatting this input:
select * from dba_tables where (owner = 'SYSTEM' and (table_name = 'REDO_DB' or table_name = 'REDO_LOG')) or (owner = 'SYS' and (table_name = 'ALERT_QT' or table_name = 'ALL_UNIFIED_AUDIT_ACTIONS'));
with the intermediate version of lightweight formatter (see #105) produces this result:
select *
from dba_tables
where (owner = 'SYSTEM' and (table_name = 'REDO_DB' or table_name = 'REDO_LOG'))
or (owner = 'SYS' and (table_name = 'ALERT_QT' or table_name = 'ALL_UNIFIED_AUDIT_ACTIONS'));
from plsql-formatter-settings.
Related Issues (20)
- Wrong indentation of comment before first when keyword in case expression
- Git pre-commit hook: Warning on empty staging area: Bypassing formatter due to partial commit.
- Update to GraalVM 22.2.0
- Wrong default file encoding on Windows HOT 10
- Do not suppress errors in SQL code blocks within Markdown files HOT 2
- Stop of SQL code blocks in Markdown files is identified wrongly HOT 2
- Building native image on Windows 11 - mvn failure HOT 17
- Line breaks after SELECT but not after FROM and WHERE HOT 8
- Formating "join - using" without linebreak HOT 8
- Remove quoted identifiers
- Update settings to make them compatible with SQLcl 22.3.0
- script format.js --register in SQLcl returns !ScriptCommand.1!@ > HOT 2
- bug when using format.js with a single file HOT 5
- formatting large files with repetitive statements, i.e. insert HOT 3
- noformat not working HOT 6
- Superb Script HOT 2
- Package constant formatting HOT 1
- Function header formatting: return deterministic HOT 1
- Support SQLDev 23.1.0 HOT 1
- Add - Formatierung "CASE WHEN" in SELECT statemen HOT 4
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 plsql-formatter-settings.