Caps and an exclamation -- so you know this must be important. :-)

There is a bug with the current version of Refactor where lines do not get a CR/LF at the end.

Consider the following statement and note (1) the commented line and (1) the use of CR instead of CR/LF:
1: DELETE FROM Users <CR>
2: WHERE <CR>
3: Status='A'<CR>
4:  -- AND UsrID = '1234'<CR>
5: AND AccountID = 'Bob'<CR>

Sql Mgt Studio will color only the commented line as a comment, but when the statement is run, it will consider the line 5 as part of the comment. This means the following statement gets run:
DELETE FROM Users WHERE Status='A' -- AND UsrID = '1234' AND AccountID = 'Bob'

Note that everything after the comment got commented out.

This is because Refactor only did a CR instead of a CR/LF.

So when it would appear that you would only be deleting users where Status='A' and AccountID='Bob', you end up deleting all users where Status='A', regardless if the AccountID.

In my particular case I ran Refactor against a SPROC and then ran the SPROC. The bug of the missing CR/LF was previously reported by another user.

I think this also shows a bug in Sql Mgt Studio. It should have colored the rest of the statement as a comment if that is how it was going to behave.

Remember, it's a beta!
rjpaulsen
0

Comments

3 comments

  • Andras B
    rjpaulsen wrote:
    Caps and an exclamation -- so you know this must be important. :-)

    There is a bug with the current version of Refactor where lines do not get a CR/LF at the end.

    Consider the following statement and note (1) the commented line and (1) the use of CR instead of CR/LF:
    1: DELETE FROM Users <CR>
    2: WHERE <CR>
    3: Status='A'<CR>
    4:  -- AND UsrID = '1234'<CR>
    5: AND AccountID = 'Bob'<CR>
    

    Sql Mgt Studio will color only the commented line as a comment, but when the statement is run, it will consider the line 5 as part of the comment. This means the following statement gets run:
    DELETE FROM Users WHERE Status='A' -- AND UsrID = '1234' AND AccountID = 'Bob'
    

    Note that everything after the comment got commented out.

    This is because Refactor only did a CR instead of a CR/LF.

    So when it would appear that you would only be deleting users where Status='A' and AccountID='Bob', you end up deleting all users where Status='A', regardless if the AccountID.

    In my particular case I ran Refactor against a SPROC and then ran the SPROC. The bug of the missing CR/LF was previously reported by another user.

    I think this also shows a bug in Sql Mgt Studio. It should have colored the rest of the statement as a comment if that is how it was going to behave.

    Remember, it's a beta!

    Many thanks for this bug report, this issue should be fixed now, and will be available in the next beta.

    Andras
    Andras B
    0
  • rjpaulsen
    There's going to be another Beta? When?
    rjpaulsen
    0
  • Andras B
    rjpaulsen wrote:
    There's going to be another Beta? When?

    Very soon :)

    (we will release a new beta soon with a large number of extra refactorings very soon (sorry, I would not like to commit to exact dates now). We will send out a notification once it is out)

    Andras
    Andras B
    0

Add comment

Please sign in to leave a comment.