erlangbureau / jamdb_oracle

Oracle Database driver for Erlang
MIT License
103 stars 46 forks source link

First line comment in the SQL statement fails the query. #142

Closed vasumur closed 5 months ago

vasumur commented 11 months ago

As you see below if the first line is a comment then the query is not returning any results, but as soon as remove the first line commend it works

iex(15)> query
"-- first line comment\nselect 'x' as dummy from dual\n"

iex(16)> Ecto.Adapters.SQL.query(MyRepo, query, [],[])
{:ok, %{rows: [[]], num_rows: 1}}

iex(17)> query1
"\nselect 'x' as dummy from dual\n"

iex(18)> Ecto.Adapters.SQL.query(SMyRepo, query1, [],[])
{:ok, %{columns: ["DUMMY"], rows: [["x"]], num_rows: 1}}
vstavskyi commented 11 months ago

just move comment to the end

vstavskyi commented 11 months ago

try new function strip commit

sql = Jamdb.Oracle.strip(sql)

vasumur commented 11 months ago

Was wondering if this can be done prior to the execution in the library?

This should help with any logging sql without stripping comments etc that rely on those comments for readability etc.