Comments (8)
If you do not want to have a line break before using
you have to uncheck the option Line Breaks -> On ANSI joins
as in the following screen shot:
To align the table aliases you have to check additionally the option Alignment -> Column and Table aliases
as in the next screenshot:
There is no option to align the USING
keywords when Line Breaks -> On ANSI joins
is unchecked.
Please note that you need to terminate the SQL statements with ;
if you want to format multiple statements.
from plsql-formatter-settings.
(...) Is there maybe a way to enable multi- to single-line formating?
Yes, of course. One option is to use the original formatter settings provided by the SQLDev team. Their settings configure a heavyweight formatter. This means the whitespace between tokens is not preserved (beside some exceptions) and therefore the formatter result will always look the same. If you are not happy with the formatter result you can contact the SQLDev team via the SQLDev forum or open a SR on MOS.
Another option is to amend the Arbori program provided in this repository. For that it's probably the easiest to fork this repository. A quick but incomplete hack would be to change the section I7 on line 890. Change wsBefore
to " "
. This will enforce a single space between all tokens. The problem is, that you do not really want that. You want to preserve some line breaks, e.g. those before the join
keyword in your example. When the option Line Breaks On ANSI joins
is unchecked there will be no line breaks before join
nor using
. Furthermore a lot of other statements will be badly formatted, e.g. create table statements
. Basically every statement which the lightweight formatter keeps mostly "as is". So this change will completely break the lightweight formatter. But of course you can change the formatter settings further to exactly produce the result you want.
Yet another approach is to change the behavior of the option Line Breaks On ANSI joins
. You find the relevant code by searching for breakAnsiiJoin
which is a boolean variable representing the checkbox for this option. You might want to change the Arbori query o10_join_clause_keywords. Commenting out line 2397 might be a simple solution to avoid line breaks before the using
keyword even when Line Breaks On ANSI joins
is enabled.
In any case, we do not plan to make such changes in our formatter settings.
Is there a way to align all "using" after the aliases / table names?
Yes, of course. One option is to harmonize the length of the table aliases. In your example change advp
to at
and voilà the using
keyword is automatically aligned.
Another option is to add a formatter section which explicitly aligns the using
keyword. It will be similar to the code section O5: Alignment: Column and Table aliases. Options: true; false. (alignTabColAliases). You find the the nodes to be aligned with the following Arbori query:
using_nodes:
[scope) from_clause
& [node) on_using_condition
& scope < node
;
Similar as with column aliases and table aliases, you have to make sure that each using
keyword is on a dedicated line, otherwise the alignment will produce a mess. The logic for that is also implemented in section O5
. You have to copy and amend it accordingly.
In any case, we do not plan to make such changes in our formatter settings.
from plsql-formatter-settings.
closing due to inactivity.
from plsql-formatter-settings.
Thanks for the explanation. The "col/tab alias" part works great.
The "ANSI" Join part works not so well:
- Converting short (single line) to long (multi lines) works.
- Converting long (multi lines) to short (single line) doesn't works.
n.b.: My inactivity was due to the nice thing called holidays :-)
from plsql-formatter-settings.
Converting long (multi lines) to short (single line) doesn't works.
This is intended. See https://github.com/Trivadis/plsql-formatter-settings#nice-to-know .
from plsql-formatter-settings.
Okay - I didn't see it in the "nice tto know" - Is there maybe a way to enable multi- to single-line formating?
n.b.: Thanks again for the helpful hints, I think the alias-align will help me and the "using" stuff will be fine.
from plsql-formatter-settings.
Is there a way to align all "using" after the aliases / table names?
from plsql-formatter-settings.
Thank you for all the helpful hints to improve my workflow
from plsql-formatter-settings.
Related Issues (20)
- 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
- 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
- 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
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.