@@ -36,7 +36,7 @@ defmodule AshPostgres.DataLayer do
3636
3737alias Ash.Filter
3838alias Ash.Filter . { Expression , Not , Predicate }
39- alias Ash.Filter.Predicate . { Eq , GreaterThan , In , LessThan }
39+ alias Ash.Filter.Predicate . { Eq , GreaterThan , In , IsNil , LessThan }
4040alias AshPostgres.Predicates.Trigram
4141
4242import AshPostgres , only: [ table: 1 , repo: 1 ]
@@ -87,9 +87,11 @@ defmodule AshPostgres.DataLayer do
8787def can? ( _ , { :filter_predicate , _ , % Eq { } } ) , do: true
8888def can? ( _ , { :filter_predicate , _ , % LessThan { } } ) , do: true
8989def can? ( _ , { :filter_predicate , _ , % GreaterThan { } } ) , do: true
90+ def can? ( _ , { :filter_predicate , _ , % IsNil { } } ) , do: true
9091def can? ( _ , { :filter_predicate , :string , % Trigram { } } ) , do: true
9192def can? ( _ , { :filter_predicate , _ } ) , do: false
9293def can? ( _ , { :sort , _ } ) , do: true
94+ def can? ( _ , _ ) , do: false
9395
9496@ impl true
9597def in_transaction? ( resource ) do
@@ -723,6 +725,15 @@ defmodule AshPostgres.DataLayer do
723725)
724726end
725727
728+ defp filter_value_to_expr ( attribute , % IsNil { nil?: true } , _type , current_binding , params ) do
729+ { params , { :is_nil , [ ] , [ { { :. , [ ] , [ { :& , [ ] , [ current_binding ] } , attribute ] } , [ ] , [ ] } ] } }
730+ end
731+
732+ defp filter_value_to_expr ( attribute , % IsNil { nil?: false } , _type , current_binding , params ) do
733+ { params ,
734+ { :not , [ ] , [ { :is_nil , [ ] , [ { { :. , [ ] , [ { :& , [ ] , [ current_binding ] } , attribute ] } , [ ] , [ ] } ] } ] } }
735+ end
736+
726737defp filter_value_to_expr (
727738attribute ,
728739% Trigram { } = trigram ,