-
Notifications
You must be signed in to change notification settings - Fork 41
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
'preload' results in 'Complex :in queries is not supported' error #62
Comments
@Qqwy can you contribute a test that reproduces it? We do support some |
Of course! I am building a chat application, and this is what I am doing: Schemas:defmodule MyApp.Chat.User do
use Ecto.Schema
import Ecto.Changeset
schema "users" do
belongs_to :app, MyApp.Chat.App
field :name, :string
has_many :sent_messages, MyApp.Chat.Message
timestamps()
end
end defmodule MyApp.Chat.Message do
use Ecto.Schema
import Ecto.Changeset
schema "message" do
belongs_to :sender, MyApp.Chat.User
belongs_to :conversation, MyApp.Chat.Conversation
field :content, :string
timestamps()
end
end Migrations:defmodule MyApp.Repo.Migrations.CreateUsers do
use Ecto.Migration
def change do
create table(:users) do
add :name, :string
add :app_id, :integer #references("apps")
timestamps()
end
end
end defmodule MyApp.Repo.Migrations.CreateMessage do
use Ecto.Migration
def change do
create table(:message) do
add :sender_id, :integer # references("users")
add :conversation_id, :integer # references("conversations")
add :content, :string
timestamps()
end
end
end (For this example, the 'conversation' schema and 'apps' schema are not really important) I then attempt the following query: from(MyApp.Chat.Message, where: [conversation_id: ^conversation_id], order_by: [desc: :inserted_at], limit: 10)
|> preload(:sender)
|> MyApp.Repo.all() to fetch all Messages which should each contain there respective sender. I am not entirely sure how to extract a test out of this, but hopefully it does give you some indication of what is going on. (I try to run |
When using an
Ecto.Query.preload(:relation_name)
in a pipeline with a query, the following error is thrown:This error is not indicative of what is happening here, so:
a) we need a better error.
b) maybe it is possible to support this feature after all?
The text was updated successfully, but these errors were encountered: