Skip to content

Conversation

@jechol
Copy link
Contributor

@jechol jechol commented Dec 30, 2025

Depends on ash-project/ash#2497

Summary

Add SQL translation for is_distinct_from and is_not_distinct_from functions to PostgreSQL's IS DISTINCT FROM and IS NOT DISTINCT FROM operators.

Example

# Ash query
Order
|> Ash.Query.filter(is_distinct_from(shipping_phone, primary_phone))

# Generated SQL
WHERE shipping_phone IS DISTINCT FROM primary_phone

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

Add support for generating SQL IS DISTINCT FROM and IS NOT DISTINCT FROM expressions.

- Update AshSql.Expr to handle :is_distinct_from and :is_not_distinct_from operators
- Generate proper SQL: "expr1 IS DISTINCT FROM expr2" and "expr1 IS NOT DISTINCT FROM expr2"

This enables NULL-safe comparisons in SQL queries generated by AshSql.

Related to ash-project/ash#2493
…ions

Add SQL translation for Ash.Query.Function.IsDistinctFrom and IsNotDistinctFrom.

Changes:
- Import IsDistinctFrom and IsNotDistinctFrom functions
- Add unified handler for both functions using pattern matching
- Generate SQL IS DISTINCT FROM and IS NOT DISTINCT FROM operators
- Remove old operator-based handling code

Implementation:
- Both functions handled in single default_dynamic_expr clause
- Uses guard clause: when mod in [IsDistinctFrom, IsNotDistinctFrom]
- SQL fragment selection via case statement
- Enables NULL-safe comparisons in PostgreSQL queries
@jechol jechol changed the title feat: add SQL generation for is_distinct_from operators feat: add support for is_distinct_from and is_not_distinct_from functions Dec 31, 2025
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.

1 participant