Single quotes when not pasting inside the code sample Box

  • Thom A

    SSC Guru

    Points: 98029

    Now, I realise this is really a user problem; people are just pasting their code into the code box and not caring that is an unreadable mess (which, for me just puts me off answering the question in all honesty), however, when these users are pasting, it seems that the Forum Software is also breaking the code. Take the following statement below:

    SELECT *
    FROM MyTable
    WHERE ID = 1
    AND Name = 'Thom'
    AND Status != '';

    And now I'll paste it into the window instead:

    SELECT *

    FROM MyTable

    WHERE ID = 1

    AND Name = 'Thom'

    AND Status != '';

    Now, when editting (which I am now), it looks fine, but in the display 'Thom' is now ‘Thom’, so the quote characters are incorrect. As for Status != '' it is now Status != ”; it's turned the 2 single quotes into a single double quote. It's also inserted an extra line break between each line of code.

    Like I said, I realise that this is a user problem not making use of the tools they have; but the forum software shouldn't be invalidating the code. If, somehow, we can stop users pasting code straight into the question that would be great, but if not can we try to make it so that at least it's useable? It's very hard help users, when the code they've supplied has been broken by the forum software (due to the user's own fault however).

    If we copy and paste the code from the display of the reply, we can this query, which needs fixing before anyone can run it:

    SELECT *

    FROM MyTable

    WHERE ID = 1

    AND Name = ‘Thom’

    AND Status != ”;

    Unfortunately, you can't see the double line breaks, which you would if you pasted into something like SSIS/ADS/etc.

    • This topic was modified 1 month ago by  Thom A.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.

  • Jeff Moden

    SSC Guru

    Points: 993661

    I'd suggest that each forum have a "sticky" topic on it for how to post various types of code along with mention of how to post question either for coded answers or performance issues.  Of course (and I've not checked today) the forums seem to be having problems with attachments, especially on older posts.

     

    Regardless of the instructions, I agree that the forum code should do things like automatic smart-quotes, etc, etc.

    The instructions would help either way but shouldn't be used as a reason to not fix the paste problems.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
    "If you think its expensive to hire a professional to do the job, wait until you hire an amateur."--Red Adair
    "Change is inevitable... change for the better is not."
    When you put the right degree of spin on it, the number 3|8 is also a glyph that describes the nature of a DBAs job. 😉

    Helpful Links:
    How to post code problems

  • Steve Jones - SSC Editor

    SSC Guru

    Points: 714105

    Styling and pasting are still being worked on. There are lots of interactions between the "rules" of how to interpret pasting and then the precedence of those.

    Smart quotes and left/right ticks are a common thing in language, but not in code. We should disable those because left/right ticks serve no purpose here.

     

  • Eirikur Eiriksson

    SSC Guru

    Points: 182321

    I've noticed the "translation" issue of the single quote (char(39)) where it's converted into opening-closing single quotes, in my mind, a definite no-no when it comes to SQL scripts!

    😎

    Same thing sometimes happens when - is converted to a MS Word style hyphen, guess Steve and the crew has some work to do 😉

     

  • Sue_H

    SSC Guru

    Points: 89729

    Smart quotes are only good for testing find and replace functionality.

    Sue

  • bmg002

    SSC-Insane

    Points: 22160

    This may be an unpopular opinion, but I feel that this is more of a user training issue than a forum software issue.

    If the end user uses the tool the way it was designed (ie clicking on the "insert/edit code sample" button), this is not a problem.

    To me this feels more like how some forums have a sticky set of rules you need to abide by before posting;  I don't think there is a need to tweak the tool in this case.

    That being said, I know I get frustrated with tools that try to format my writing for me.  If I put a single quote in or 2 dashes, maybe I actually meant to put in a single quote or 2 dashes.

    The formatting of text in this new form to me feels a lot like MS Word's formatting.  Enter puts in a large gap between paragraphs, shift+enter does not.  2 dashes becomes 1 wider dash, apostrophes when a closing one is found become "smart" quotes.  For those who are familiar with MS Word, this new forum software is pretty easy to figure out.

    Not sure it is possible, but having a "plain text" mode vs "smart" mode for the text editor may make things nicer for everyone?

    I think knowing the hotkey or symbol which triggers the editor to tell me that it is a "code sample" vs wall of text would be helpful.  I think having the tool automatically guess what is and isn't code will result in a bunch of garbled up posts.

  • Thom A

    SSC Guru

    Points: 98029

    bmg002 wrote:

    This may be an unpopular opinion, but I feel that this is more of a user training issue than a forum software issue. If the end user uses the tool the way it was designed (ie clicking on the "insert/edit code sample" button), this is not a problem.

    I do agree that really this is a user issue, and if the software was used correctly this wouldn't be a problem. Many of us, however, are more than aware how difficult it is to get our own users in our companies to use an application they are "trained" on correctly, so I honestly believe we have no chance of educating strangers on the internet.

     

    Plus the fact that more inventive validation makes for more inventive idiots, means that no matter how much the Redgate team may try to stop users pasting code as raw text they'll never stop them. 😉

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.

  • Steve Jones - SSC Editor

    SSC Guru

    Points: 714105

    A quote test:

    SELECT *
    FROM MyTable
    WHERE ID = 1
    AND Name = 'Thom'
    AND Status !='';

    Fingers crossed

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply