Comments (8)
To produce the expected result you can change the Arbori queries o6_select_before
and o6_select_after
like that:
o6_select_before:
[parent) subquery
& (
[node) 'SELECT'
)
& parent < node
;
o6_select_after:
[parent) subquery
& (
[node) 'SELECT'
)
& parent < node
;
These queries provide the node for the option SELECT/FROM/WHERE
. In this case it considers only SELECT
and all other keywords like WITH
, INTO
, FROM
, WHERE
, CONNECT
, START
, GROUP
, HAVING
, ORDER
are ignored.
I suggest to change the Arbori program in an external editor and not in the preferences dialog.
from plsql-formatter-settings.
This is a lightweight formatter.
So, if you add a line break in one of the select terms, the result is as you expect.
If you want to enforce every select_term
on a new line then have a look at the JS in the Arbory query a16_add_line_breaks_before
. Especially this if statement. You might want to comment it out.
from plsql-formatter-settings.
I have not tried with 22.2.1 yet. It works with 22.2.0.
Unformatted:
select * from dual where dummy = 'X';
Formatter result:
select
*
from
dual
where
dummy = 'X';
Can you please provide the input you've tried, the formatter settings you've used the effective and the expected result? Thank you.
from plsql-formatter-settings.
Thank you for the reply. This use case might not be possible with the standard SQL Developer preferences, but I just wanted to see before trying to understand the Arbori syntax.
Unformatted
select 1, 2, 3
from dual
where 1 = 1 and 2 = 2;
Formatter Results
select 1,
2,
3
from dual
where 1 = 1
and 2 = 2;
Expected Results
select
1,
2,
3
from dual
where 1 = 1
and 2 = 2;
Here are my SQL Developer Advanced Format settings
from plsql-formatter-settings.
Thanks. I can reproduce your results.
With the current settings it is not possible to produce your expected result. I see two problems:
-
You do not want to have keywords right-aligned, but the
and
should be right-aligned withwhere
.
It's an unusual formatting style and not covered by the settings nor in the Arbori program. However, you can achieve what you want by adapting the Arbori program. -
You just want to a line break after
select
but not afterfrom
andwhere
.
The option is for all keywords (e.g. also for theorder by
) and not just for theselect
. There is no option for that in SQLDev. However, it's doable, but you have to adapt the Arbori program yourself.
I hope this answers your question.
from plsql-formatter-settings.
- You do not want to have keywords right-aligned, but the and should be right-aligned with where.
It's an unusual formatting style and not covered by the settings nor in the Arbori program. However, you can achieve what >you want by adapting the Arbori program
Correction. It's just indented by 2 spaces, not right-aligned.
I guess it's probably the easiest to check SELECT/FROM/WHERE
and write an Arbori fix-rule at the end.
from plsql-formatter-settings.
Thank you, I am not very familiar with the Arbori rules, so I will take a look. I went ahead and closed the issue.
from plsql-formatter-settings.
That is fantastic, it worked. I will play with the Arbori program to help resolve the issue with break after commas in select list. FROM and WHERE clause work with your example.
select
1, 2, 3
from dual
where 1 = 1
and 2 = 2;
from plsql-formatter-settings.
Related Issues (20)
- 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
- Newlines being inserted into strings HOT 4
- Concatenation Bars being split apart invalidating strings HOT 2
- compiler flag concatenated to same line as end statement HOT 2
- Support SQLcl 23.3
- Do not reset Arbori program when importing trivadis_advanced_format.xml
- Unwanted line break after `whenever oserror` breaks code
- Wrong indentation in subqueries of with_clause in insert statements
- Unwanted line break before `on conversion error` in subquery
- spaces removed in grant statement
- Patching SQL Developer breaks Script Output tab feedback of direct SQL statement execution HOT 8
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.