Skip to content

FOR JSON PATH throws off syntax validation in query editor #12

Description

Issue Type: Bug

The text FOR JSON PATH seems to be ignored by syntax validation in the query editor.

Start with a valid query. There are no syntax errors and the query returns results:
image

Now, if we simply add FOR JSON PATH, we get no syntax error in the editor, but when we try to run the query, it errors because we didn't name the (JSON) column. It's invalid syntax, but the editor thinks the CTE has two named columns.
image

This is also evident in Intellisense: the CTE is interpreted as having two named columns, even though, because of FOR JSON PATH, it just has one unnamed column.
image

If we explicitly name the column name, the editor thinks there is a syntax error (bug). The editor thinks the CTE still has two columns. SQL returns the expected value (expected behavior).
image

If we specify two names in the CTE definition, the editor thinks it's valid syntax (bug), but it throws a SQL error when you execute it (expected behavior):
image

We get the same behavior regardless of whether or not the CTE is defined with the WITH keyword.
image

We get the same behavior with table variables, not just the VALUES keyword.
image

Azure Data Studio version: azuredatastudio 1.34.0 (83a4316cf89cbf961a0f09a72c861379cfd01fa9, 2021-12-15T20:47:33.863Z)
OS version: Windows_NT x64 10.0.19043
Restricted Mode: No

System Info
Item Value
CPUs Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz (4 x 2904)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 15.73GB (4.12GB free)
Process Argv
Screen Reader no
VM 0%
Extensions: none

Activity

  1. alanrenmsft commented on Feb 3, 2022

    @alanrenmsft

    Charles Gagnon (@Charles-Gagnon) do you know whether we are using the latest parser?

  2. Charles-Gagnon commented on Feb 3, 2022

    @Charles-Gagnon
    Contributor

    Looks like it, yeah.

    https://github.com/Microsoft/sqltoolsservice/blob/main/Packages.props#L28

    <PackageReference Update="Microsoft.SqlServer.Management.SqlParser" Version="160.21292.55" />

    https://www.nuget.org/packages/Microsoft.SqlServer.Management.SqlParser/

    Does this repro in SSMS? That's usually what I do first to check if this is an issue in the parser or in ADS.

  3. alanrenmsft commented on Feb 8, 2022

    @alanrenmsft

    chatted with Matteo, SSMS also has the same problem, this needs to be fixed in sql parser. put this in backlog for now and will look into it when I get time.

  4. timothylcooke commented on Feb 8, 2022

    @timothylcooke
    Author

    For future reference, if I ever run into another parsing issue that reproduces in SSMS, is there a better repository I should have reported this to?

    Perhaps https://github.com/Microsoft/sqltoolsservice/

  5. alanrenmsft commented on Feb 8, 2022

    @alanrenmsft

    Tim Cooke (@timothylcooke) it doesn't matter, it is the same group of folks working on these repos, and logically, i think it makes sense to report here to make it easy for other users to find (most of the ADS users do not know sqltoolsservice).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions