def broken_db_query(param) do
query = from p in "table",
where: p.param == ^param,
select: p.something
Repo.all(query)
end
This will work if ^param is replaced with a valid column name string literal. Also If I say ^"param" instead this will run but just return nothing from the query.
When I make the query with the pin operator it shows in the debug -
[debug] SELECT t0.[something] FROM [table] AS t0 WHERE (t0.[param] = @1) ["Param"] OK
which returns []
But when it's just a string literal -
SELECT t0.[something] FROM [table] AS t0 WHERE (t0.[param] = CONVERT(nvarchar(max), 0x70006100720061006d0020)) [] OK
this returns the desired values
This will work if ^param is replaced with a valid column name string literal. Also If I say ^"param" instead this will run but just return nothing from the query.
When I make the query with the pin operator it shows in the debug - [debug] SELECT t0.[something] FROM [table] AS t0 WHERE (t0.[param] = @1) ["Param"] OK which returns []
But when it's just a string literal - SELECT t0.[something] FROM [table] AS t0 WHERE (t0.[param] = CONVERT(nvarchar(max), 0x70006100720061006d0020)) [] OK this returns the desired values
Elixir version: Erlang/OTP 19 [erts-8.3] [64-bit] [smp:8:8] [async-threads:10]
Elixir 1.4.4
MSSQL version: 10.50.2500.0.
I am still very new to elixir so please let me know if there's something obvious I'm doing wrong here, or if this is the wrong place to ask.
Thanks!