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

Commit817e6cc

Browse files
committed
WIP
1 parent80230b6 commit817e6cc

File tree

1 file changed

+35
-56
lines changed

1 file changed

+35
-56
lines changed

‎lib/data_layer.ex‎

Lines changed: 35 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,9 @@ defmodule AshPostgres.DataLayer do
151151
defcan?(_,:filter),do:true
152152
defcan?(_,:limit),do:true
153153
defcan?(_,:offset),do:true
154-
defcan?(_,{:filter_operator,%Eq{right:%Ref{}}}),do:false
154+
defcan?(_,{:filter_operator,%{right:%Ref{}}}),do:false
155155
defcan?(_,{:filter_operator,%Eq{left:%Ref{}}}),do:true
156+
defcan?(_,{:filter_operator,%In{left:%Ref{}}}),do:true
156157
defcan?(_,{:filter_predicate,_,%In{}}),do:true
157158
defcan?(_,{:filter_predicate,_,%LessThan{}}),do:true
158159
defcan?(_,{:filter_predicate,_,%GreaterThan{}}),do:true
@@ -889,36 +890,36 @@ defmodule AshPostgres.DataLayer do
889890
end
890891

891892
defpfilter_to_expr(
892-
%Eq{left:%Ref{}=left,right:%Ref{}=right,operator::==},
893+
%Eq{left:%Ref{}=left,right:right,embedded?:embedded?},
893894
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
895+
params,
896+
embedded?
906897
)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))]}}
898+
simple_operator_expr(
899+
:==,
900+
params,
901+
right,
902+
left.attribute.type,
903+
ref_binding(left,bindings),
904+
left.attribute,
905+
embedded?
906+
)
911907
end
912908

913909
defpfilter_to_expr(
914-
%Eq{left:%Ref{}=left,right:right},
910+
%In{left:%Ref{}=left,right:map_set,embedded?:embedded?},
915911
bindings,
916912
params
917913
)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))]}}
914+
simple_operator_expr(
915+
:in,
916+
params,
917+
MapSet.to_list(map_set),
918+
{:in,left.attribute.type},
919+
ref_binding(left,bindings),
920+
left.attribute,
921+
embedded?
922+
)
922923
end
923924

924925
defpfilter_to_expr(%Predicate{}=pred,bindings,params)do
@@ -947,21 +948,18 @@ defmodule AshPostgres.DataLayer do
947948
)
948949
end
949950

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)
951+
defpref_binding(ref,bindings)do
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)
957957

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]},[],[]}
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
965963
end
966964

967965
defparam_binding(ix)do
@@ -1006,25 +1004,6 @@ defmodule AshPostgres.DataLayer do
10061004
)
10071005
end
10081006

1009-
defpfilter_value_to_expr(
1010-
attribute,
1011-
%In{values:values},
1012-
type,
1013-
current_binding,
1014-
params,
1015-
embedded?
1016-
)do
1017-
simple_operator_expr(
1018-
:in,
1019-
params,
1020-
values,
1021-
{:in,type},
1022-
current_binding,
1023-
attribute,
1024-
embedded?
1025-
)
1026-
end
1027-
10281007
defpfilter_value_to_expr(
10291008
attribute,
10301009
%IsNil{nil?:true},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp