@@ -151,28 +151,41 @@ create or replace package body ut_suite_cache_manager is
151151
152152 return l_results;
153153 end;
154+
154155 /*
155- The object name is populate but suitepath not
156- We will use that object and try to match.
157- We can pass also a wildcard this will result in one to many.
156+ First SQL queries for objects where procedure is null or its only wildcard.
157+ We split that due to fact that we can use func min to combine rows.
158+
159+ Second union is responsible expanding paths where the procedure filter is given
160+ We cannot select min here as filter can cover only half of tests within
161+ package. Even if the filter doesnt return anything we still capture a proc filter
162+ name for error reporting later on.
158163
159- Get all data that do not have an wildcard and not require expanding.
160- We will take them as they are.
161- a)suite path is populated
162- b)suite path and object is empty so schema name is by default ( or passed)
164+ Third SQL cover scenario where a suitapath only is populated and wildcard is given
165+
166+ Fourth SQL cover scenario where suitepath is populated with no filters
163167 */
164168 function expand_paths(a_schema_paths ut_path_items) return ut_path_items is
165169 l_schema_paths ut_path_items:= ut_path_items();
166170 begin
167171 with paths_to_expand as (
168172 select /*+ no_parallel */ min(path) as suite_path,sp.schema_name as schema_name,nvl(c.object_name,sp.object_name) as object_name,
169- nvl2(sp.procedure_name,c.name,null) as procedure_name
173+ null as procedure_name
174+ from table(a_schema_paths) sp left outer join ut_suite_cache c
175+ on ( c.object_owner = upper(sp.schema_name)
176+ and c.object_name like replace(upper(sp.object_name),'*','%'))
177+ where sp.suite_path is null and sp.object_name is not null
178+ and ( sp.procedure_name is null or sp.procedure_name = '*')
179+ group by sp.schema_name,nvl(c.object_name,sp.object_name)
180+ union all
181+ select /*+ no_parallel */ path as suite_path,sp.schema_name as schema_name,nvl(c.object_name,sp.object_name) as object_name,
182+ nvl(c.name,sp.procedure_name) as procedure_name
170183 from table(a_schema_paths) sp left outer join ut_suite_cache c
171184 on ( c.object_owner = upper(sp.schema_name)
172185 and c.object_name like replace(upper(sp.object_name),'*','%')
173186 and c.name like nvl(replace(upper(sp.procedure_name),'*','%'), c.name))
174187 where sp.suite_path is null and sp.object_name is not null
175- group by sp.schema_name,nvl(c.object_name, sp.object_name),nvl2( sp.procedure_name,c.name,null)
188+ and ( sp.procedure_name is not null and sp.procedure_name != '*')
176189 union all
177190 select /*+ no_parallel */ nvl(c.path,sp.suite_path) as suite_path,sp.schema_name,sp.object_name,sp.procedure_name as procedure_name
178191 from
@@ -218,18 +231,17 @@ create or replace package body ut_suite_cache_manager is
218231 from ut_suite_cache c,
219232 table(a_schema_paths) sp
220233 where c.object_owner = upper(sp.schema_name)
221- and (
222- (sp.suite_path is not null and
223- sp.suite_path||'.' like c.path||'.%' /*all parents and self*/
224- or
225- ( c.path||'.' like sp.suite_path||'.%' /*all children and self*/
226- and c.object_name like nvl(upper(sp.object_name ),c.object_name)
227- and c.name like nvl(upper(sp.procedure_name),c.name) ) )
234+ and ((sp.suite_path is not null and sp.suite_path||'.' like c.path||'.%' /*all parents and self*/
235+ or
236+ (
237+ c.path||'.' like sp.suite_path||'.%' /*all children and self*/
238+ and c.object_name like nvl(upper( sp.object_name),c.object_name)
239+ and c.name like nvl(upper(sp.procedure_name ),c.name)
240+ ) )
228241 or
229242 ( sp.suite_path is null
230- and c.object_name like nvl(upper(replace(sp.object_name,'*','%')),c.object_name)
231- and c.name like nvl(upper(replace(sp.procedure_name,'*','%')),c.name)
232- ))) where r_num = 1;
243+ and c.object_name = nvl(upper(sp.object_name),c.object_name)
244+ and c.name = nvl(upper(sp.procedure_name),c.name)))) where r_num =1;
233245 return l_suite_items;
234246 end;
235247
0 commit comments