Skip to content

Conversation

jimsynz
Copy link
Contributor

@jimsynz jimsynz commented Oct 1, 2025

This partially reverts the changes in 3cad640.

I don't actually know what any of this code does, but it seems that the missing Ash.Query.Function.Type at the root of the expression causes weird typing issues. The customer app does have a lot of their own types added to Postgrex using Postgrex.Types.define/3.

Here's what the customer was seeing:

     ** (Ash.Error.Unknown)
     Bread Crumbs:
       > Error returned from: App.Domain.Resource.action

     Unknown Error

     * ** (DBConnection.EncodeError) Postgrex expected an integer in -9223372036854775808..9223372036854775807, got "update_failed". Please make sure the value you are passing matches the definition in your table or in your query or convert the value accordingly.
       (app 0.1.0) deps/postgrex/lib/postgrex/type_module.ex:1084: App.Core.PostgrexTypes.encode_list/3
       (postgrex 0.21.1) lib/postgrex/extensions/array.ex:88: Postgrex.Extensions.Array.encode/4
       (postgrex 0.21.1) lib/postgrex/extensions/array.ex:58: Postgrex.Extensions.Array.encode/3
       (app 0.1.0) deps/postgrex/lib/postgrex/type_module.ex:1084: App.Core.PostgrexTypes.encode_params/3
       (postgrex 0.21.1) lib/postgrex/query.ex:75: DBConnection.Query.Postgrex.Query.encode/3
       (db_connection 2.8.1) lib/db_connection.ex:1446: DBConnection.encode/5
       (db_connection 2.8.1) lib/db_connection.ex:1546: DBConnection.run_prepare_execute/5
       (db_connection 2.8.1) lib/db_connection.ex:769: DBConnection.parsed_prepare_execute/5
       (db_connection 2.8.1) lib/db_connection.ex:761: DBConnection.prepare_execute/4
       (ecto_sql 3.13.2) lib/ecto/adapters/postgres/connection.ex:102: Ecto.Adapters.Postgres.Connection.prepare_execute/5
       (ecto_sql 3.13.2) lib/ecto/adapters/sql.ex:1004: Ecto.Adapters.SQL.execute!/5
       (ecto_sql 3.13.2) lib/ecto/adapters/sql.ex:996: Ecto.Adapters.SQL.execute/6
       (ecto 3.13.3) lib/ecto/repo/queryable.ex:241: Ecto.Repo.Queryable.execute/4
       (ash_postgres 2.6.20) lib/data_layer.ex:1581: AshPostgres.DataLayer.update_query/4
       (ash 3.5.43) lib/ash/actions/update/bulk.ex:608: Ash.Actions.Update.Bulk.do_atomic_update/5
       (ash 3.5.43) lib/ash/data_layer/data_layer.ex:449: Ash.DataLayer.transaction/4
       (ash 3.5.43) lib/ash/actions/update/bulk.ex:276: Ash.Actions.Update.Bulk.run/6
       (app 0.1.0) deps/ash/lib/ash/code_interface.ex:1131: App.Domain.SecondResource.second_action/3
       (app 0.1.0) lib/app/domain/resource/changes/third_action_change.ex:19: anonymous fn/3 in App.Domain.Resource.Changes.ThirdActionChange.change/3
       (ash 3.5.43) lib/ash/changeset/changeset.ex:4706: anonymous fn/2 in Ash.Changeset.run_after_actions/3

This partially reverts the changes in 3cad640.
@jimsynz jimsynz requested a review from zachdaniel October 1, 2025 22:04
@zachdaniel
Copy link
Contributor

I'll need to see a failing test in ash_postgres or something to explain how we're getting to this issue.

@stevebrambilla
Copy link
Contributor

@zachdaniel I've got a repro case for this here: stevebrambilla/ash_postgres@ce6a83f

That new test fails with ash_sql pointed to main, and works on this branch.

@zachdaniel
Copy link
Contributor

@stevebrambilla mind PR-ing that failing test?

@zachdaniel
Copy link
Contributor

@jimsynz feel free to merge once the credo issue is fixed 🙇

@stevebrambilla
Copy link
Contributor

Opened the PR here: ash-project/ash_postgres#629

@zachdaniel zachdaniel merged commit bc61a53 into main Oct 4, 2025
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants