Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit80230b6

Browse files
committed
WIP
1 parent10cedb3 commit80230b6

File tree

1 file changed

+57
-20
lines changed

1 file changed

+57
-20
lines changed

‎lib/data_layer.ex‎

Lines changed: 57 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ defmodule AshPostgres.DataLayer do
7272
}
7373

7474
aliasAsh.Filter
75-
aliasAsh.Filter.{Expression,Not,Predicate}
76-
aliasAsh.Filter.Predicate.{Eq,GreaterThan,In,IsNil,LessThan}
75+
aliasAsh.Filter.{Expression,Not,Predicate,Ref}
76+
aliasAsh.Filter.Predicate.{GreaterThan,IsNil,LessThan}
77+
aliasAsh.Filter.Operator.{Eq,In}
7778
aliasAshPostgres.Predicates.Trigram
7879

7980
importAshPostgres,only:[table:1,repo:1]
@@ -150,8 +151,9 @@ defmodule AshPostgres.DataLayer do
150151
defcan?(_,:filter),do:true
151152
defcan?(_,:limit),do:true
152153
defcan?(_,:offset),do:true
154+
defcan?(_,{:filter_operator,%Eq{right:%Ref{}}}),do:false
155+
defcan?(_,{:filter_operator,%Eq{left:%Ref{}}}),do:true
153156
defcan?(_,{:filter_predicate,_,%In{}}),do:true
154-
defcan?(_,{:filter_predicate,_,%Eq{}}),do:true
155157
defcan?(_,{:filter_predicate,_,%LessThan{}}),do:true
156158
defcan?(_,{:filter_predicate,_,%GreaterThan{}}),do:true
157159
defcan?(_,{:filter_predicate,_,%IsNil{}}),do:true
@@ -886,6 +888,39 @@ defmodule AshPostgres.DataLayer do
886888
{params,{:not,[],[new_expression]}}
887889
end
888890

891+
defpfilter_to_expr(
892+
%Eq{left:%Ref{}=left,right:%Ref{}=right,operator::==},
893+
bindings,
894+
params
895+
)do
896+
left=ref_to_field(left,bindings)
897+
right=ref_to_field(right,bindings)
898+
899+
{params,{:==,[],[left,right]}}
900+
end
901+
902+
defpfilter_to_expr(
903+
%Eq{left:%Ref{}=left,right:right},
904+
bindings,
905+
params
906+
)do
907+
left_ref=ref_to_field(left,bindings)
908+
909+
{params++[{right,op_type(left.attribute.type)}],
910+
{:==,[],[left_ref,param_binding(Enum.count(params))]}}
911+
end
912+
913+
defpfilter_to_expr(
914+
%Eq{left:%Ref{}=left,right:right},
915+
bindings,
916+
params
917+
)do
918+
left_ref=ref_to_field(left,bindings)
919+
920+
{params++[{right,op_type(left.attribute.type)}],
921+
{:==,[],[left_ref,param_binding(Enum.count(params))]}}
922+
end
923+
889924
defpfilter_to_expr(%Predicate{}=pred,bindings,params)do
890925
%{predicate:predicate,relationship_path:relationship_path,attribute:attribute}=pred
891926

@@ -912,23 +947,25 @@ defmodule AshPostgres.DataLayer do
912947
)
913948
end
914949

915-
defpfilter_value_to_expr(
916-
attribute,
917-
%Eq{value:value},
918-
type,
919-
current_binding,
920-
params,
921-
embedded?
922-
)do
923-
simple_operator_expr(
924-
:==,
925-
params,
926-
value,
927-
type,
928-
current_binding,
929-
attribute,
930-
embedded?
931-
)
950+
defpref_to_field(ref,bindings)do
951+
binding=
952+
caseref.attributedo
953+
%Ash.Resource.Attribute{}->
954+
Enum.find_value(bindings,fn{binding,data}->
955+
data.path==ref.relationship_path&&data.typein[:inner,:left,:root]&&binding
956+
end)
957+
958+
%Ash.Query.Aggregate{}=aggregate->
959+
Enum.find_value(bindings,fn{binding,data}->
960+
data.path==aggregate.relationship_path&&data.type==:aggregate&&binding
961+
end)
962+
end
963+
964+
{{:.,[],[{:&,[],[binding]},ref.attribute.name]},[],[]}
965+
end
966+
967+
defparam_binding(ix)do
968+
{:^,[],[ix]}
932969
end
933970

934971
defpfilter_value_to_expr(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp