You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sample code (place in file.fsx, then run dotnet fsi --exec file.fsx):
`#r "nuget: Microsoft.SqlServer.DacFx"
open System.IO
open System.Collections.Generic
open Microsoft.SqlServer.TransactSql.ScriptDom
let parse sql =
let parser = TSql160Parser(false)
use textReader = new StringReader(sql) :> TextReader
let mutable errors : IList<> = Unchecked.defaultof<IList<>>
let res = parser.Parse(textReader, &errors)
match errors.Count with
| 0 -> res
| _ -> failwith $"parse error\n\n{sql}"
let visitor = {
new TSqlFragmentVisitor() with
override this.Visit(proc:ProcedureStatementBody) =
match Option.ofObj proc.StatementList with
| Some sl -> printfn $"line: {sl.StartLine} column: {sl.StartColumn}"
| _ -> ()
}
let proc = """
CREATE PROCEDURE dbo.usp_add_kitchen @dept_id INT, @kitchen_count INT NOT NULL
WITH EXECUTE AS OWNER, SCHEMABINDING, NATIVE_COMPILATION
AS
BEGIN ATOMIC WITH (TRANSACTION ISOLATION LEVEL = SNAPSHOT, LANGUAGE = N'us_english')
UPDATE dbo.Departments
SET kitchen_count = ISNULL(kitchen_count, 0) + @kitchen_count
WHERE ID = @dept_id
END;
"""
let parsed = parse proc
parsed.Accept(visitor)
`
result is:
line: 5 column: 50
which points to value of first ATOMIC WITH option, "SNAPSHOT" here
expected result:
line: 5 column: 1
The text was updated successfully, but these errors were encountered:
@kisantia@dzsquared this should be labeled with the scriptdom label to help track it. And it reproduces in C# and on Windows, so it is not a F# issue by any means.
Steps to Reproduce:
sample code (place in file.fsx, then run dotnet fsi --exec file.fsx):
`#r "nuget: Microsoft.SqlServer.DacFx"
open System.IO
open System.Collections.Generic
open Microsoft.SqlServer.TransactSql.ScriptDom
let parse sql =
let parser = TSql160Parser(false)
use textReader = new StringReader(sql) :> TextReader
let mutable errors : IList<> = Unchecked.defaultof<IList<>>
let res = parser.Parse(textReader, &errors)
match errors.Count with
| 0 -> res
| _ -> failwith $"parse error\n\n{sql}"
let visitor = {
new TSqlFragmentVisitor() with
override this.Visit(proc:ProcedureStatementBody) =
match Option.ofObj proc.StatementList with
| Some sl -> printfn $"line: {sl.StartLine} column: {sl.StartColumn}"
| _ -> ()
}
let proc = """
CREATE PROCEDURE dbo.usp_add_kitchen @dept_id INT, @kitchen_count INT NOT NULL
WITH EXECUTE AS OWNER, SCHEMABINDING, NATIVE_COMPILATION
AS
BEGIN ATOMIC WITH (TRANSACTION ISOLATION LEVEL = SNAPSHOT, LANGUAGE = N'us_english')
UPDATE dbo.Departments
SET kitchen_count = ISNULL(kitchen_count, 0) + @kitchen_count
WHERE ID = @dept_id
END;
"""
let parsed = parse proc
parsed.Accept(visitor)
`
result is:
line: 5 column: 50
which points to value of first ATOMIC WITH option, "SNAPSHOT" here
expected result:
line: 5 column: 1
The text was updated successfully, but these errors were encountered: