elixir-sqlite / ecto_sqlite3

An Ecto SQLite3 adapter.
https://hexdocs.pm/ecto_sqlite3
MIT License
295 stars 43 forks source link

fragments in select #104

Closed ruslandoga closed 10 months ago

ruslandoga commented 1 year ago

This query doesn't seem to work with SQLite3 https://github.com/elixir-sqlite/ecto_sqlite3/blob/6dcc0b2410ac2e2727d6c81ecb2e96c410eb8be4/test/ecto/adapters/sqlite3/connection_test.exs#L139-L144

sqlite> create table example(a integer);

sqlite> select e0 from "example" as e0;
Parse error: no such column: e0
  select e0 from "example" as e0;
         ^--- error here

I wonder if there is something we can do about it. Either raise or add .*.

ruslandoga commented 1 year ago

Postgrex has a similar test case

https://github.com/elixir-ecto/ecto_sql/blob/c7d58a3f963cc605ef73c4eec2c03fc46c6db804/test/ecto/adapters/postgres_test.exs#L87-L88

But it seems to work in PostgreSQL: I've tried select u0 from users u0.

warmwaffles commented 1 year ago

Oh that's confusing. We should do what is right and just raise here honestly. Doing a naked select like that and appending .* seems risky to me. Calls to the DB should be explicit and not so ambiguous. Thoughts?