Comments (2)
@Qqwy can you contribute a test that reproduces it? We do support some :in
queries, but they are emulated by nested :or
's and don't work in all possible cases.
from ecto_mnesia.
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.
Executing this query fails with the error shown above (Complex :in queries is not supported by the Mnesia adapter.
).
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 Ecto.Query.preload
on a field that is a belongs_to
in my schema).
from ecto_mnesia.
Related Issues (20)
- Support for "rename table" HOT 2
- Record does not get deleted in on_exit callback HOT 2
- [error] Could not retrieve migrated versions. HOT 6
- Support insert_all/3 with source HOT 1
- Discuss the importance of Ecto migrations for ecto_mnesia HOT 5
- Unique index , associations and :in query clausal HOT 1
- "Schema :users does not exist" while the DB has been created and migrated HOT 9
- Error on migration containing `references(...)` field type HOT 2
- Problem with queries including timestamps HOT 1
- order_by: and limit: seem to be EXTREMELY slow HOT 1
- Getting :cyclic abort when using Repo.Transaction in case of multiple process. HOT 1
- Preload fail because the foreign key is used, instead of the primary key
- Streams: EctoMnesia does not support Ecto streams, and the custom EctoMnesia.Table.Stream uses records rather than structs
- Are there any plans to support Ecto 3.0? HOT 1
- Ecto.Multi errors result in `CaseClauseError {:error, :rollback}` rather than the error that was raised in the Ecto.Multi function. HOT 2
- Will this adapter be updated to Ecto v3? HOT 1
- Current Status? HOT 1
- What do we do with the migrations runner in this project? HOT 4
- Support for Ecto 3 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ecto_mnesia.