-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
Using the examples on the dynamic sql page
This works
type ExampleQueryResult =
{ Id : int
Name : string
Email: string
}
let exampleCommand (id : int) (nameSearch : string) =
dynamicCommand<ExampleQueryResult>
[| sql "SELECT Id, Name, Email FROM USERS"
sql " WHERE Id = "
arg id
sql " OR Name LIKE "
arg ("%" + nameSearch + "%")
|]
This fails
type MyMostlyStaticQuery = SQL<"""
SELECT Id, Name, Email FROM USERS
WHERE unsafe_inject_raw(@dynSql)
""">
let exampleCommand2 (id : int) (nameSearch : string) =
let exampleSql =
[| sql "Id = "
arg id
sql " OR Name LIKE "
arg ("%" + nameSearch + "%")
|]
MyMostlyStaticQuery.Command(dynSql = exampleSql)
Error is Incorrect syntax near '<'.
Calling the above 2 examples with args 1 and "Mojo", it appears the fragments for exampleCommand2 is invalid as below
Example 1 Fragments
[|CommandText "SELECT Id, Name, Email FROM USERS"; CommandText " WHERE Id = ";
InlineParameter (Int32,1); CommandText " OR Name LIKE ";
InlineParameter (String,"%Mojo%")|]
Example 2 Fragments
[|CommandText "SELECT"; LineBreak; Indent; CommandText "[USERS].[Id]"; LineBreak;
CommandText ", [USERS].[Name]"; LineBreak; CommandText ", [USERS].[Email]";
Outdent; LineBreak; CommandText "FROM "; Indent; CommandText "[USERS]";
Outdent; LineBreak; CommandText "WHERE "; Indent; CommandText "((";
Parameter 0; CommandText ")<>0)"; Outdent; CommandText ";"; LineBreak|]
Is there a way to log or capture the final sql statement that is executed?
Is this error from the usage or a bug?
Metadata
Metadata
Assignees
Labels
No labels