Format wants to capitalize the OPENJSON "key" column to "Key"

I can't for the life of me find out how to stop SQL Prompt from formatting the built-in column name of "key" (must be all lower-case in my BIN2 collation for it to work) to the camel-case "Key" when I'm using a SELECT [key] FROM OPENJSON(). Is this a bug?
Tagged:

Answers

  • Number2Number2 Posts: 4 New member
    Now that I mention it, the [value] column also gets CamelCased to [Value] every time too.
  • James RJames R Posts: 104 Silver 4
    Hey @Number2 ,

    Just to check, have you tried turning off the formatting option under Global > Casing > User-defined objects > Use object definition case? I think that the Key and Value columns are declared as camel-case.

    If this doesn't help then let me know!
    Thanks,
    James
    Software Engineer
    Redgate Software
  • Number2Number2 Posts: 4 New member
    When I turn that off, then it casts them as all uppercase instead of camel.
  • way0utwestway0utwest Posts: 312 Rose Gold 1
    edited September 25, 2017 4:55PM
    Which version of SQL Prompt? If I turn off the option for user defined objects, I get things formatted as:

    DECLARE @json NVARCHAR(4000)
    = N'{
    "key":1,
    "name" : { "firstname":"Steve", "lastname":"Jones"} ,
    "Employer":"Redgate",
    "Sites":{ "primary":"SQLServerCentral", "secondary":"tsqltuesday.com"}
    }'
    ;
    SELECT [key] FROM OPENJSON(@json) AS oj
    ;
  • Number2Number2 Posts: 4 New member
    OK, I see what's happening...we've got two things causing this. One is the formatting from CTRL+K,CTRL+Y and the other is the inline-formatting/replacing feature like when you have SELECT * FROM OPENJSON() and then hit TAB when you're on that * to have it auto-expand that star into the columns. That one will also convert them to Key Value camel.

    So, with USER-DEFINED OBJECTS -> USE OBJECT DEFINITION CASE as UNCHECKED, the CTRL+K, CTRL+Y formatting does NOT exhibit this problem, but the TAB expansion of columns where it replaces text as you're typing, that DOES still camel case it for me.

    Version 8.0.11.2296
Sign In or Register to comment.