IBM / db2forzosdeveloperextension-about

IBM Db2 for z/OS Developer Extension for VS Code
https://IBM.github.io/db2forzosdeveloperextension-about/
Other
12 stars 7 forks source link

Add SQL format feature #19

Closed patbossman closed 3 years ago

patbossman commented 3 years ago

This was a topic of conversation on Db2-L. https://www.idug.org/communities/community-home/digestviewer/viewthread?GroupId=253&MessageKey=b0da67c5-14a8-4726-b51d-32e5d24ec6ab&CommunityKey=02a8700a-dc76-4190-9a3c-24f0738c1067&tab=digestviewer&ReturnUrl=%2fcommunities%2fcommunity-home%2fdigestviewer%3fcommunitykey%3d02a8700a-dc76-4190-9a3c-24f0738c1067%26tab%3ddigestviewer#bmb0da67c5-14a8-4726-b51d-32e5d24ec6ab

There's a desire to simply format the original SQL to make it readable.

phil-sevetson commented 3 years ago

Pat, thank you for opening this discussion.

My particular challenge (I'm the OP of the DB2-L thread) was to deal with DB2 z/OS SQL generated by Cognos BI, with deeply nested selects and mixes of inner and outer joins, within unions. Additional problems included BETWEEN predicates describing date ranges, and long lists of predicates connected by "AND".

  1. Vertically aligning, and visually connecting, parenthetic pairs would help greatly.
  2. It's probably necessary to include the ability to say, "Break before the AND in a sequence of predicates" and have several other tunable settings.
  3. Last thought of the day: it wouldn't hurt to have formatting profiles save-and-name-able. Styles of coding SQL vary widely enough that a one-size-fits-all approach to the formatting task would undoubtedly produce visually degraded code for some of the styles while helping others.
realkendrickren commented 3 years ago

@phil-sevetson @patbossman this is also one item in our roadmap. Thanks for the feedback.

realkendrickren commented 3 years ago

@phil-sevetson Hi Phil, we just published v1.2.0, it supports formatting SQL and many other enhancements. Please upgrade and give a try, let us know if you have any questions. Thanks.

phil-sevetson commented 3 years ago

I see this. Thank you. I'll talk with Pat and get the Developer package installed. /phil