-
-
Notifications
You must be signed in to change notification settings - Fork 132
feat: support offset option in lateral join queries #700
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,6 +65,33 @@ defmodule AshPostgres.Test.LoadTest do | |
| |> Map.get(:latest_comment) | ||
| end | ||
|
|
||
| test "has_one with offset returns the correct record" do | ||
| post = | ||
| Post | ||
| |> Ash.Changeset.for_create(:create, %{title: "title"}) | ||
| |> Ash.create!() | ||
|
|
||
| %{id: first_comment_id} = | ||
| Comment | ||
| |> Ash.Changeset.for_create(:create, %{title: "first"}) | ||
| |> Ash.Changeset.manage_relationship(:post, post, type: :append_and_remove) | ||
| |> Ash.create!() | ||
|
|
||
| :timer.sleep(1) | ||
|
|
||
| Comment | ||
| |> Ash.Changeset.for_create(:create, %{title: "second"}) | ||
| |> Ash.Changeset.manage_relationship(:post, post, type: :append_and_remove) | ||
| |> Ash.create!() | ||
|
|
||
| # second_latest_comment: sort(created_at: :desc), offset(1) => first comment | ||
| assert %{id: ^first_comment_id} = | ||
| Post | ||
| |> Ash.Query.load(:second_latest_comment) | ||
| |> Ash.read_one!() | ||
| |> Map.get(:second_latest_comment) | ||
| end | ||
|
Comment on lines
+68
to
+93
|
||
|
|
||
| test "belongs_to relationships can be loaded" do | ||
| assert %Comment{post: %Ash.NotLoaded{type: :relationship}} = | ||
| comment = | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -756,6 +756,12 @@ defmodule AshPostgres.Test.Post do | |||||||
| public?(true) | ||||||||
| end | ||||||||
|
|
||||||||
| has_one :second_latest_comment, AshPostgres.Test.Comment do | ||||||||
| sort(created_at: :desc) | ||||||||
| offset(1) | ||||||||
|
||||||||
| offset(1) | |
| offset(1) | |
| from_many?(true) |
Uh oh!
There was an error while loading. Please reload this page.