How can we help you today? How can we help you today?

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?
allnelsons
0

Comments

5 comments

  • Number2
    Now that I mention it, the [value] column also gets CamelCased to [Value] every time too.
    Number2
    0
  • James R
    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
    James R
    0
  • Number2
    When I turn that off, then it casts them as all uppercase instead of camel.
    Number2
    0
  • way0utwest
    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
    ;
    way0utwest
    0
  • Number2
    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
    Number2
    0

Add comment

Please sign in to leave a comment.