[Solved] Smart alignment -- ON plus AND/OR

20 Posts
3 Users
0 Reactions
4,776 Views
Posts: 7
Topic starter
(@hwmonkey)
Member
Joined: 2 years ago
[#129]

The join is arguably the most important part of SQL, and when one of our coders gets it wrong, the most troublesome. We implemented a formatting standard to expedite clarity of reading the joins for the really complex ones, that involve AND or OR. It really is just aligning the AND/OR keywords with the ON. Code would look something like:

 SELECT
     na.*
   , zian.abbr
   , net.field2
 FROM note_actions na
   INNER JOIN myschema.tbl_edit_trail  net  ON na.note_id  = net.note_id
   INNER JOIN myschema.tbl_emp         emp  ON emp.user_id = net.user_id
                                           AND emp.prac_id = na.prac_id
   INNER JOIN myschema.tbl_nose       zian  ON net.nose_c  = zian.note_c
                                            OR na.nose_c   = zian.note_c
 WHERE
     zian.abbr = 'CON'

Currently, I cannot figure out how to do this with SQLinForm


19 Replies
Guido
Posts: 295
Admin
(@admin)
Member
Joined: 5 years ago

Hi @hwmonkey,

when a linebreak is inserted beforte AND/OR in a JOIN statement it starts at the left margin or at (left margin + one indent level). Its position is not based upon the position of the ON. But this sounds like a good idea for a future  release

grafik

Regards

Guido


Reply
2 Replies
(@hwmonkey)
Joined: 2 years ago

Member
Posts: 7

Thanks @admin,

Thank you for the recommended settings. Thank you for considering this feature in a future release. Once a person gets used to it being formatted like this, it is remarkably easy to quickly debug/understand.


Reply
(@lompies)
Joined: 2 years ago

Member
Posts: 5

@admin I am a new happy user and this was the first thing I was looking for. Please add my vote!


Reply
Guido
Posts: 295
Admin
(@admin)
Member
Joined: 5 years ago

@lompies , @hwmonkey

it took some time but now I have changed the logic for the AND/OR Alignment for JOIN Statements as required.

Would you like to do some Beta-Testing?

Regards

Guido


Reply
2 Replies
(@lompies)
Joined: 2 years ago

Member
Posts: 5

@admin Yes - sign me up!


Reply
(@hwmonkey)
Joined: 2 years ago

Member
Posts: 7

Posted by: @admin

@lompies , @hwmonkey

it took some time but now I have changed the logic for the AND/OR Alignment for JOIN Statements as required.

Would you like to do some Beta-Testing?

1. Thank you

2. Rewriting sections of code can be challenging. I get it. And I appreciate it.

3. Answer: It depends on your timeline for implementation. I definitely am willing, but I am heavily committed to projects at the moment and I cannot commit to anything for probably 3 weeks.

 


Reply
Guido
Posts: 295
Admin
(@admin)
Member
Joined: 5 years ago

@lompies , @hwmonkey

When you have some free time, you can test it by downloading the new Release (Desktop app or N++ Plugin) and use the higlighted option (see screenshot)

grafik

Thanks for your feedback and this great idea


Reply
2 Replies
(@hwmonkey)
Joined: 2 years ago

Member
Posts: 7

@admin -- The screenshot makes me so happy. Thank you. And I hope other coders use it and discover how much easier it is to read when formatted like this.


Reply
(@lompies)
Joined: 2 years ago

Member
Posts: 5

@admin Cannot get it to work? See video


Reply
Guido
Posts: 295
Admin
(@admin)
Member
Joined: 5 years ago

I can't see any AND/OR keywords in the ON clauses. Please add a few AND/OR clauses and it should work


Reply
2 Replies
(@lompies)
Joined: 2 years ago

Member
Posts: 5

@admin I tried that.

image

It looks like you are aligning the = signs not the OR?

I don't understand the conditions - remember I'm not a coder

image

Why are there two columns?


Reply
(@lompies)
Joined: 2 years ago

Member
Posts: 5

This looks the way I like it!

Maybe I had spaces in the first example.

How do I get the AS to align?

image

Reply
Page 1 / 2
Share: