Skip to content

comparing against range_lower raises on ash_postgres #2884

Description

@matt-beanland

Code of Conduct

  • I agree to follow this project's Code of Conduct

AI Policy

  • I agree to follow this project's AI Policy, or I agree that AI was not used while creating this issue.

Versions

Elixir 1.20.2
Erlang/OTP 29 (erts-17.0.3)
ash main @ f3a27d9 (unreleased; mix.exs still says 3.31.3)

Operating system

macOS 26.5.2 (Darwin 25.5.0) aarch64

Current Behavior

range_lower(stay) == ^datetime raises on ash_postgres, and works on Ash.DataLayer.Ets.

Reproduction

in iex:

Mix.install([{:ash, github: "ash-project/ash", ref: "f3a27d9f5"}])

{:ok, c} = Ash.Type.init(Ash.Type.Range, inner_type: :datetime)

ref = %Ash.Query.Ref{
  attribute: %Ash.Resource.Attribute{name: :stay, type: Ash.Type.Range, constraints: c},
  relationship_path: [],
  resource: nil
}

Ash.Expr.determine_types(
  Ash.Query.Operator.Eq,
  [%Ash.Query.Function.RangeLower{arguments: [ref]}, ~U[2026-03-01 00:00:00Z]]
)
#=> {[{Ash.Type.Range, [...]}, {Ash.Type.Range, [...]}], {Ash.Type.Boolean, []}}

Both operands come back as Ash.Type.Range, including the DateTime.

Expected Behavior

The other operand should be typed as the range's inner type. type/2 around the literal is the workaround.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions