Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ms sql server method names are incorrectly considered case-insensitive #3967

Closed
cpcloud opened this issue Aug 25, 2024 · 0 comments · Fixed by #3969
Closed

ms sql server method names are incorrectly considered case-insensitive #3967

cpcloud opened this issue Aug 25, 2024 · 0 comments · Fixed by #3969
Assignees

Comments

@cpcloud
Copy link
Contributor

cpcloud commented Aug 25, 2024

In [4]: sql = """
   ...: SELECT
   ...: TOP 10
   ...:   s.RECORDID, /* , rd.FormContent */
   ...:   n.c.value('(/*:FORM_ROOT/*:SOME_TAG)[1]', 'float') AS SOME_TAG_VALUE
   ...: FROM source_table.dbo.source_data AS s(nolock)
   ...:     CROSS APPLY FormContent.nodes('/*:FORM_ROOT') AS N(C)
   ...: """

In [5]: import sqlglot.expressions as sge, sqlglot as sg

In [6]: print(sg.parse_one(sql, read="tsql").sql('tsql', pretty=True))
SELECT
TOP 10
  s.RECORDID, /* , rd.FormContent */
  n.c.VALUE('(/*:FORM_ROOT/*:SOME_TAG)[1]', 'float') AS SOME_TAG_VALUE
FROM source_table.dbo.source_data AS s(nolock) CROSS APPLY FormContent.NODES('/*:FORM_ROOT') AS N(C)

VALUE and NODES are methods on their respective objects and it is incorrect to alter their case like this.

docs: https://learn.microsoft.com/en-us/sql/t-sql/xml/xml-data-type-methods?view=sql-server-ver16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants