From b95d5de60fabdcc38fab19614b913ddc6a6de2f1 Mon Sep 17 00:00:00 2001 From: Stephan Hug Date: Sat, 7 Jun 2025 21:46:02 +0200 Subject: [PATCH] fix: casting integers to string in expressions works as intended This commit currently only adds a failing test. --- test/support/resources/post.ex | 6 ++++++ test/type_test.exs | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/test/support/resources/post.ex b/test/support/resources/post.ex index 4b893048..369283bc 100644 --- a/test/support/resources/post.ex +++ b/test/support/resources/post.ex @@ -154,6 +154,12 @@ defmodule AshPostgres.Test.Post do defaults([:read, :destroy]) + read :with_version_check do + argument(:version, :integer) + + filter(expr(type(^arg(:version), :string) in ["1", "2"])) + end + read :first_and_last_post do prepare(fn query, _ -> Ash.Query.combination_of(query, [ diff --git a/test/type_test.exs b/test/type_test.exs index 428fcab1..4c3731e7 100644 --- a/test/type_test.exs +++ b/test/type_test.exs @@ -100,4 +100,11 @@ defmodule AshPostgres.Test.TypeTest do assert %{x: 2.0, y: 3.0, z: 4.0} = p.db_string_point_id assert %{x: 2.0, y: 3.0, z: 4.0} = p.db_string_point.id end + + test "casting integer to string works" do + Post |> Ash.Changeset.for_create(:create) |> Ash.create!() + + post = Ash.Query.for_read(Post, :with_version_check, version: 1) |> Ash.read!() + refute is_nil(post) + end end