Welcome to SQLDBcontrol Forums Sign in | Join | Help
in

Feature requests

Last post 05-19-2009, 16:46 by admin. 8 replies.
Sort Posts: Previous Next
  •  05-12-2009, 22:28 247

    Feature requests

    I would like a code formatter that can go through and format after you are finished editing. One of the problems I run into is inconsistent formatting from developer to developer. Even it the automatic formatting is sub-optimal it would be better than no formatting at all.

    Also I think that all SQL keywords and built in functions should be in ALL CAPS rather than Mixed Case. It would be nice to have an option for that. And if you don't want to get into code formatting then it would be nice to have an function the reset the case for all keywords to the case you have set as default.

    Thanks!
  •  05-13-2009, 8:06 249 in reply to 247

    Re: Feature requests

    By default all T-SQL keywords should be automatically converted to upper case.  If this isn't happening then check to see if you have the option "Auto-case correct T-SQL keywords" enabled in Tools > Options (Editor tab).

    Also, if you want to you can instantly convert all T-SQL keywords in a specific editor to upper case by selecting "Auto-Case T-SQL Keywords" from the Edit menu.

    Regarding code formatting, this will be harder to implement but should be possible (in some shape of form at least).  The most important thing is defining what "formatted code" should look like - everyone has a different idea of what this is.

    To start with I suggest we look at seperating the keywords in select, insert, delete & update statements so that they start on seperate lines - we can then worry about indentations and how to handle nested statements.  Feel free to provide your own ideas regarding formatting.


    SQLDBcontrol Support

    support@sqldbcontrol.com
  •  05-13-2009, 14:51 252 in reply to 249

    Re: Feature requests

    You are right, the capitalization is working in my current version. It didn't work in the previous and I didn't notice that it is working now. Also I agree that syntax formatting is difficult for SQL. There are so many different ways that I have seen it done, and only mine is any good. That was supposed to be funny. Thanks!
  •  05-19-2009, 11:22 263 in reply to 252

    Re: Feature requests

    We've started work on implementing some code formatting fucntionality and we're now able to format select, update, insert and delete statements (including joins, or & and clauses).

    It's actually more complex than it appears at first because we have to parse the entire document, searching out for these keywords and then decide what formatting rules to apply to any document space before and after the keywords (including indentation amounts).

    What we've got so far seems to work pretty well and it takes about 10 seconds to format 3000 lines of T-SQL code - hopefully you won't have written too many scripts that are that long.

    We aren't yet dealing with nested statements or with T-SQL code that is bounded by brackets as this involves some additional complexity.  But we'll be starting on this next.

    The other thing we'll need to work on is providing some options to allow users to define what rules to apply to formatting.  For now with gone with the following simple formatting structure shown below.

    At this point, if you have any preferences regarding the formatting let us know and we'll include options to suit your preferences (e.g. commas should start on a new line, and statements should appear at the end of a line rather than the start, etc.)

    select
               col1, 
               col2,
               col3
    from   
               table1 
               inner join table2 on table2.col1 = table1.col2 
    where   
               col1 = 22
    and      col2 > 35
    or        col3 = 45

    --columns appear on a new line and indented
    --from statements appear on a new line and in-line with the preceding select statement
    --tables appear on a new line and indented
    --join statements appear on a new line and in-line with the previous line
    --where statements appear on a new line and in-line with the preceding select statement


    SQLDBcontrol Support

    support@sqldbcontrol.com
  •  05-19-2009, 14:46 264 in reply to 263

    Re: Feature requests

    There are so many ways to format SQL. I think that you should do what would be the easiest to implement consistently. For what it is worth I generally code like this:

    SELECT col1
    , col2
    , col3
    FROM table1
    JOIN table2 on table2.col1 = table1.col2
    AND table2.col2 = table1.col3
    WHERE col1 = 22
    AND col2 IN (
    My correlated subquery
    )

    But I can understand that this might be difficult to do. I do this was because it is the way my first boss wanted it. Yours is actually very clear to read.

    My thoughts behind having a formatter in SQLDBC isn't going to fix all problems. You will never end up with with perfect automatic formatting but anything to help consistency would be a boon for someone new to a codebase.

    Thanks!
  •  05-19-2009, 15:28 265 in reply to 264

    Re: Feature requests

    I like the idea of having a formatter but I will be difficult to implement something that will work for everyone.  I like having the commas in front of the columns as indicated above.  I also like to right justify the first keyword on a line and then left justify everything else.  This is how I would like the format to be for the above query...

    SELECT col1

                   ,col2

                  ,col3

      FROM table1

     INNER JOIN table2 ON table2.col1 = table1.col2

         AND table2.col2 = table1.col3

     WHERE col1 = 22

         AND col2 IN (subquery)

    The SELECT, FROM, INNER, AND, and WHERE keywords are right justified and everything else is left justified.

    I think you would have to have a dedicated tab to under Tools->Options to make it flexible enough for everyone to customize it to their liking.

  •  05-19-2009, 16:01 267 in reply to 265

    Re: Feature requests

    We'll definately be implementing a dedicated tab in Tools > Options.  Initially we'll probably just include obvious options like whether to place commas at the beginning of a line or at the end, and whether certain keywords should appear on a new line or indented.

    Thereafter, as more people start using it will include options that deal with specific needs.  Obviously though, as you pointed out, there is a limit to how far we can go to get something working for everyone.

    We'll hopefully have something working that includes nested statements and a few options by the end of this week or beginning of next week.

    If you'd like a copy of that build so you can evaluate it please let me know and I'll make it available.


    SQLDBcontrol Support

    support@sqldbcontrol.com
  •  05-19-2009, 16:23 268 in reply to 267

    Re: Feature requests

    I would gladly test the build if it didn't require a DB schema upgrade that required the other developers to upgrade as well.

    I am on version 2.1.21000
  •  05-19-2009, 16:46 269 in reply to 268

    Re: Feature requests

    That's possible as we have an option to disable schema updates with new builds.

    I'll let you know once the functionality is ready.


    SQLDBcontrol Support

    support@sqldbcontrol.com
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems