Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use values: "SQLite3 does not support table prefixes" #138

Open
dlindenkreuz opened this issue Dec 19, 2023 · 5 comments
Open

Cannot use values: "SQLite3 does not support table prefixes" #138

dlindenkreuz opened this issue Dec 19, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@dlindenkreuz
Copy link

dlindenkreuz commented Dec 19, 2023

I am trying to use the values/2 macro to filter results by matching compound keys (group_name, name).

vals =
  Enum.map(rows, fn row ->
    %{group_name: row.group_name, name: row.name}
  end)

Repo.all(
  from s in Symbol,
    join: v in values(vals, %{group_name: :string, name: :string}),
    on: [group_name: s.group_name, name: s.name],
)

With SQLite, this error is raised:

** (ArgumentError) SQLite3 does not support table prefixes
    (ecto_sqlite3 0.13.0) lib/ecto/adapters/sqlite3/connection.ex:1894: Ecto.Adapters.SQLite3.Connection.quote_table/2
    (ecto_sqlite3 0.13.0) lib/ecto/adapters/sqlite3/connection.ex:1573: Ecto.Adapters.SQLite3.Connection.create_name/3
    (ecto_sqlite3 0.13.0) lib/ecto/adapters/sqlite3/connection.ex:1553: Ecto.Adapters.SQLite3.Connection.create_names/4
    (ecto_sqlite3 0.13.0) lib/ecto/adapters/sqlite3/connection.ex:1554: Ecto.Adapters.SQLite3.Connection.create_names/4
    (ecto_sqlite3 0.13.0) lib/ecto/adapters/sqlite3/connection.ex:1548: Ecto.Adapters.SQLite3.Connection.create_names/2
    (ecto_sqlite3 0.13.0) lib/ecto/adapters/sqlite3/connection.ex:174: Ecto.Adapters.SQLite3.Connection.all/2
    (ecto_sqlite3 0.13.0) lib/ecto/adapters/sqlite3.ex:184: Ecto.Adapters.SQLite3.prepare/2
    (ecto 3.11.1) lib/ecto/query/planner.ex:182: Ecto.Query.Planner.query_without_cache/4
    (ecto 3.11.1) lib/ecto/query/planner.ex:152: Ecto.Query.Planner.query_prepare/6
    (ecto 3.11.1) lib/ecto/query/planner.ex:127: Ecto.Query.Planner.query_with_cache/8
    (ecto 3.11.1) lib/ecto/repo/queryable.ex:214: Ecto.Repo.Queryable.execute/4
    (ecto 3.11.1) lib/ecto/repo/queryable.ex:19: Ecto.Repo.Queryable.all/3
    iex:6: (file)

I added a debug statement to ecto_sqlite3 to print the arguments of quote_table/2: [(ecto_sqlite3 0.13.0) lib/ecto/adapters/sqlite3/connection.ex:1893: Ecto.Adapters.SQLite3.Connection.quote_table/2] {prefix, name} #=> {[[group_name: :string, name: :string], 2], :values}

The prefix var contains the types keyword list from values invocation and 2 indicating the number of rows. Looks like this doesn't belong there?

@warmwaffles
Copy link
Member

hmm that does seem wrong. I'll look into this.

@warmwaffles warmwaffles added the bug Something isn't working label Dec 19, 2023
@warmwaffles
Copy link
Member

Can you provide an abbreviated schema for Symbol? I'm going to pull together a test to demonstrate the bug.

@dlindenkreuz
Copy link
Author

Sure!

defmodule MyApp.Symbols.Symbol do
  use Ecto.Schema

  @primary_key false
  
  schema "symbol" do
    field :group_name, :string, primary_key: true
    field :name, :string, primary_key: true
  end
end

@warmwaffles warmwaffles self-assigned this Dec 19, 2023
@dlindenkreuz
Copy link
Author

@warmwaffles Did you get around to this? I didn't find a workaround on my end 😿

@warmwaffles
Copy link
Member

I have not yet. I'll try to get to it soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants