Comments (4)
🤔 I really don't see how this can be happening. I've added a test that mimics the behavior:
post1 =
Post
|> Ash.Changeset.new(%{title: "aaa", score: 0})
|> Api.create!()
post2 =
Post
|> Ash.Changeset.new(%{title: "bbb", score: 1})
|> Api.create!()
post3 =
Post
|> Ash.Changeset.new(%{title: "ccc", score: 0})
|> Api.create!()
PostLink
|> Ash.Changeset.new()
|> Ash.Changeset.manage_relationship(:source_post, post1, type: :append)
|> Ash.Changeset.manage_relationship(:destination_post, post3, type: :append)
|> Api.create!()
PostLink
|> Ash.Changeset.new()
|> Ash.Changeset.manage_relationship(:source_post, post2, type: :append)
|> Ash.Changeset.manage_relationship(:destination_post, post2, type: :append)
|> Api.create!()
PostLink
|> Ash.Changeset.new()
|> Ash.Changeset.manage_relationship(:source_post, post3, type: :append)
|> Ash.Changeset.manage_relationship(:destination_post, post1, type: :append)
|> Api.create!()
assert [
%{title: "aaa"},
%{title: "bbb"},
%{title: "ccc"}
] =
Api.read!(
Post
|> Ash.Query.sort(title: :asc)
|> Ash.Query.filter(linked_posts.title in ["aaa", "bbb", "ccc"])
)
assert [
%{title: "ccc"},
%{title: "bbb"},
%{title: "aaa"}
] =
Api.read!(
Post
|> Ash.Query.sort(title: :desc)
|> Ash.Query.filter(linked_posts.title in ["aaa", "bbb", "ccc"])
)
from ash_postgres.
03:07:13.082 [debug] QUERY OK source="posts" db=0.7ms queue=1.1ms
SELECT p0."id", p0."title", p0."score", p0."public", p0."category", p0."type", p0."price", p0."decimal", p0."status", p0."status_enum", p0."status_enum", p0."point", p0."uniq_one", p0."uniq_two", p0."uniq_custom_one", p0."uniq_custom_two", p0."created_at", p0."updated_at", p0."author_id" FROM "posts" AS p0 INNER JOIN "public"."post_links" AS p1 ON (p1."state"::varchar = $1) AND (p0."id" = p1."source_post_id") INNER JOIN "public"."posts" AS p2 ON (p0."type"::varchar = $2) AND (p2."id" = p1."destination_post_id") WHERE (p0."type"::varchar = $3) AND (p2."title"::varchar = ANY($4::varchar[])) ORDER BY p0."title" DESC ["active", "sponsored", "sponsored", ["aaa", "bbb", "ccc"]]
from ash_postgres.
We explicitly refer to the proper binding for sorting. If you have a chance to reproduce this in a test I'd appreciate it :)
from ash_postgres.
Had more conversation over discord and got this one resolved. Still working on the other one.
from ash_postgres.
Related Issues (20)
- polymorphic_on_delete option results in never-ending migration cycle HOT 2
- Relationships are able to cross tenants with attribute strategy HOT 1
- tables with same name and different schemas breaks migration generator logic HOT 1
- Migrations are applied incorrectly with multiple repos
- Migration bigint to bigserial, when generated? true added to attribute HOT 2
- Migration generator fails when renaming and modifying a column at same time
- Query binding error when referencing a nested relationship with a deep filter HOT 1
- {:array, :map} type can't be inserted via Ash action HOT 2
- Installing extensions with multiple repos HOT 3
- Using an aggregrate on an attribute for a relation leads to inneficient queries HOT 4
- Using expr_sort on an attribute of a relation gives a "Error while building reference" HOT 2
- Invalid SQL generated when loading an aggregate that has a sort, for a resource that also has a sort HOT 3
- Sort in join relationship causes exception
- drop tables on resources being missing HOT 2
- Api.list!/2 doesn't work with the Postgres Data Layer HOT 2
- Ash.bulk_create returns success when the insert fails and rollback HOT 1
- Support `IDENTITY` instead of serial columns
- Migration script places unique index below relationships they're needed for HOT 1
- Warning shown unnecessarily when present validation specified in atomic action HOT 2
- `has_one` with `no_attributes? true` and `from_many? true` does not apply limiting to the query HOT 4
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 ash_postgres.