Branch Coverage

lib/UR/Context.pm
Criterion Covered Total %
branch 543 746 72.7


line true false branch
58 0 266 if ($initialized)
64 0 266 unless ($UR::Context::root)
68 0 266 if (my $base_id = $ENV{'UR_CONTEXT_BASE'}) { }
70 0 0 unless ($UR::Context::base)
80 0 266 if (exists $ENV{'UR_CONTEXT_CACHE_SIZE_LOWWATER'} or exists $ENV{'UR_CONTEXT_CACHE_SIZE_HIGHWATER'})
90 0 266 if (exists $ENV{'UR_CONTEXT_MONITOR_QUERY'})
102 27 116 if (@_)
109 14 13 if (defined $cache_size_highwater and $cache_size_highwater > 0 or $light_cache or 'UR::Context::AutoUnloadPool'->_pool_count) { }
142 148115 447497 if $UR::Object::Type::bootstrapping
144 68096 379401 unless ref $self
146 0 447497 if (@_)
147 0 0 if (ref $self) { }
154 379401 68096 ref $self ? :
162 0 0 if @_ > 1
167 0 0 if $UR::Object::Type::bootstrapping
172 0 0 unless $monitor_level = $self->monitor_query
173 0 0 if substr($subject_class, 0, 4) eq 'UR::' and $monitor_level < 2
176 0 0 if (defined $rule)
178 0 0 if (not exists $_query_log_times{$rule->id}) { }
185 0 0 if ($elapsed_time)
225 1665 268389 if ($class_name->isa('UR::DataSource::RDBMS::Entity')) { }
228 0 1665 if ($params->{'namespace'}) { }
1665 0 elsif ($params->{'data_source'} and not ref $params->{'data_source'} and $params->{'data_source'}->can('get_namespace')) { }
0 0 elsif ($params->{'data_source'} and ref $params->{'data_source'} eq 'ARRAY') { }
242 0 0 unless (scalar keys %namespaces == 1)
252 1665 0 if (my $exists = 'UR::Object::Type'->get($data_source)) { }
263 0 1665 unless ($data_source)
271 4474 265580 if ($data_source)
286 32 540 if ($class_name->isa('UR::DataSource::RDBMS::Entity') or $class_name->isa('UR::DataSource::RDBMS::Entity::Ghost'))
289 0 32 unless ($namespace)
304 0 0 if (@_ > 1)
319 23 14 if ($rule->specifies_value_for($wanted_property_name))
326 0 14 unless ($wanted_property_meta)
331 5 9 if ($wanted_property_meta->is_delegated) { }
345 237068 32 if (ref $subject) { }
348 8315 228753 unless ($changes_not_counted{$property})
359 5892 231208 if ($UR::Context::Transaction::log_all_changes)
364 99698 137402 if (my $index_list = $UR::Object::Index::all_by_class_name_and_property_name{$class}{$property})
365 968 98478 unless ($property eq 'create' or $property eq 'load' or $property eq 'define')
374 98797 901 unless ($property eq 'delete' or $property eq 'unload')
388 238444 61503 if (ref $subject) { }
396 19055 280892 unless ($check_classes)
401 19055 0 $class ? :
407 299947 0 $property ? :
408 238444 61503 defined $id ? :
412 47700 43 defined $id ? :
416 252323 47624 unless @matches
419 88 47536 if (@matches > 1)
427 6 47798 if $once
441 248987 4628 unless (ref $self and $self->query_underlying_context or &Scalar::Util::blessed($_[1]))
445 247549 1438 if (exists $$all_objects_loaded{$_[0]})
447 61357 186192 if (defined(my $obj = $$all_objects_loaded{$_[0]}{$_[1]})) { }
186192 0 elsif (my $subclasses = $UR::Object::Type::_init_subclasses_loaded{$_[0]}) { }
449 0 61357 if ($is_monitor_query)
462 74888 2928661 if (exists $UR::Context::all_objects_loaded->{$subclass} and my $obj = $UR::Context::all_objects_loaded->{$subclass}{$_[1]})
465 0 74888 if ($is_monitor_query)
485 73 117297 if (ref $class)
491 73 0 if (wantarray) { }
501 11 117286 if (@extra)
503 8 3 if (scalar @extra == 2 and $extra[0] eq 'sql' || $extra[0] eq 'sql in')
516 4115 60346 if (not $rule->has_meta_options and $class->isa('UR::Object::Type') || $class->isa('UR::Singleton') || $class->isa('UR::DataSource::QueryPlan'))
520 0 56920 unless defined wantarray
521 26255 30665 if wantarray
523 0 30665 if (@objects > 1 and defined wantarray)
538 0 725 unless my(@id_property_names) = $class_meta->id_property_names
543 716 9 if (@id_property_names == 1) { }
545 0 714 unless (defined $id)
554 12 6 unless $rule->specifies_value_for($name)
556 9 0 if (@missed_names) { }
581 0 34 unless (defined $subclassify_by)
586 7 27 unless (defined $sub_class_name)
589 0 7 unless ($property_meta)
598 1 6 if ($property_meta->default_value) { }
2 4 elsif ($property_meta->is_calculated and ref $property_meta->calculate eq 'CODE') { }
0 4 elsif ($property_meta->is_calculated and not ref $property_meta->calculate) { }
3 1 elsif ($property_meta->is_delegated) { }
609 1 1 unless ($rule->specifies_value_for($prop_name))
618 0 1 unless ($sub)
631 0 3 if (not @values) { }
1 2 elsif (@values > 1) { }
647 0 31 unless (defined $sub_class_name)
651 0 31 if ($sub_class_name eq $class)
655 1 30 unless ($sub_class_name->isa($class))
670 926 3158 unless ($memo)
706 0 7110 unless (defined $name)
711 1246 5864 if (defined $default_value)
712 6 1240 if ($prop->data_type and $prop->_data_type_as_class_name eq $prop->data_type and $prop->_data_type_as_class_name->can('get')) { }
25 1215 elsif (ref $default_value) { }
728 2 7108 if ($prop->calculated_default)
732 119 6991 if ($prop->is_many) { }
742 6249 elsif ($prop->is_delegated) { }
742 838 6272 unless ($prop->is_mutable)
756 23 1630 if ($class ne $co->class_name and $co->is_abstract and my $method = $co->subclassify_by)
764 11 915 @deep_copy_default_values ? :
802 0 4084 if ($first_sub_classification_method_name)
804 0 0 if (defined $sub_class_name and $sub_class_name ne $class)
806 0 0 unless ($sub_class_name->can($construction_method))
816 34 4050 if ($is_abstract)
828 104 3945 if (my $a = $template->{'_ambiguous_keys'})
834 725 3324 unless (defined $id)
836 9 714 unless ($id)
852 3 6 if (my $id_by = $property_objects->{$name}->id_by)
853 3 0 ref $id_by ? :
856 2 7 if ($params->{$name}) { }
1 6 elsif (@$params{@id_by}) { }
863 1 0 if exists $params->{$id_by}
870 3 3 if (ref $query eq 'HASH') { }
881 2 4 if ($prop->is_many) { }
888 0 6 if ($@)
894 60 3978 if ($deep_copy_default_values)
896 175 60 if ($params->{$name}) { }
912 13 2075 if (exists $params->{$property_name}) { }
8 2067 elsif (exists $default_values{$property_name}) { }
925 17 4 if ($immutable_properties->{$property_name})
927 0 17 unless $meta
929 2 15 unless $via
938 0 15 unless ($via_property_meta)
943 0 15 unless ($indirect_property_meta)
947 5 10 unless ($indirect_property_meta->to)
952 0 5 unless ($indirect_property_meta and $indirect_property_meta->to)
960 6 9 unless ($foreign_object)
964 0 6 unless ($foreign_object)
973 11 20 if ($join->{'foreign_class'}->isa('UR::Value'))
980 5 15 unless exists $direct_properties->{$source_property_name}
984 2 13 if ($rule->specifies_value_for($source_property_name) and $rule->value_for($source_property_name) ne $value)
1005 129 306 if (exists $params->{$property_name})
1012 4 4032 unless defined $entity
1014 512 3520 if $construction_method eq '__define__'
1027 1 2310 if (not exists $params->{$property_name} and $property_meta and $property_meta->is_calculated)
1035 25 37 unless defined $param_value
1036 0 62 unless defined $param_value
1038 0 62 if (not defined $param_value) { }
5 57 elsif ($param_value ne $class) { }
1052 100 3927 if (%$set_values)
1058 2 127 unless (ref $value eq 'ARRAY')
1062 0 186 if (ref $item eq 'ARRAY') { }
12 174 elsif (ref $item eq 'HASH') { }
1076 6 4021 if (%$indirect_values)
1082 1605 2422 if (%$immutable_properties)
1084 74 1531 if (@problems)
1091 0 89 if ($immutable_properties->{$name})
1095 0 89 if (@problem_properties)
1100 0 74 if (@errors_fatal_to_construction)
1108 512 3515 if $construction_method eq '__define__'
1121 0 102530 unless (defined $id)
1128 4 102526 if ($UR::Context::all_objects_loaded->{$class}{$id})
1136 14 102512 if ($object = $UR::DeletedRef::all_objects_deleted->{$class}{$id}) { }
1143 10 102516 if (my $ghost = $$all_objects_loaded{$class . '::Ghost'}{$id})
1148 9 1 if (my $committed_data = $ghost->{'db_committed'})
1152 1 9 if (my $unsaved_data = $ghost->{'db_saved_uncommitted'})
1163 0 102526 if ($light_cache)
1173 672 0 if (ref $entity) { }
1175 74 598 if ($entity->{'db_committed'} or $entity->{'db_saved_uncommitted'})
1188 150 272 unless exists $entity->{$prop_name}
1189 0 272 if ($prop_name eq 'data_source_id')
1193 0 272 if (ref $entity->{$prop_name} eq 'ARRAY') { }
1207 0 74 if ($do_data_source)
1213 0 74 unless ($ghost)
1220 74 74 if $entity->{$com}
1239 1998 307 if ($object->{'__get_serial'})
1250 1651 654 if ($object->{'__load'})
1265 0 2305 if ($ENV{'UR_DEBUG_OBJECT_RELEASE'})
1294 8 1 unless ($alternate_wanted_property)
1311 3 6 unless @alternate_values
1316 3 6 if (@r_values == 0) { }
6 0 elsif (@r_values == 1) { }
1347 0 5 unless ($wanted_property_meta->via)
1354 1 4 if ($linking_property_meta->reverse_as)
1356 0 1 if ($linking_property_meta->data_type ne $final_property_meta->class_name)
1366 1 4 unless $rule_template->specifies_value_for($rule_param)
1387 3 0 if (@_)
1391 2 1 if (defined $value)
1392 0 2 if ($cache_size_lowwater and $value <= $cache_size_lowwater)
1405 3 0 if (@_)
1409 0 2 if (defined $value and $cache_size_highwater and $value >= $cache_size_highwater)
1423 0 362 if substr($class, 0, -6) eq '::Type'
1425 250 112 unless exists $$all_objects_loaded{$class . '::Type'}
1427 56 56 unless $class_meta
1428 32 24 unless $class_meta->is_uncachable
1440 37 5 if $is_pruning
1442 1 4 unless defined $cache_size_highwater and defined $cache_size_lowwater
1443 0 4 unless $all_objects_cache_size > $cache_size_highwater
1447 0 4 if ($ENV{'UR_DEBUG_OBJECT_RELEASE'} or $ENV{'UR_DEBUG_OBJECT_PRUNING'})
1461 11 10 unless exists $data_source_for_class{$class}
1468 0 4 if $cache_size_highwater < 1
1469 0 4 if $cache_size_lowwater < 1
1490 42 2173 unless defined $obj
1491 287 1886 if ($obj->is_weakened or $obj->is_prunable and $obj->{'__get_serial'} and $obj->{'__get_serial'} <= $target_serial)
1495 0 287 if ($ENV{'UR_DEBUG_OBJECT_RELEASE'})
1508 0 4 if ($ENV{'UR_DEBUG_OBJECT_RELEASE'} or $ENV{'UR_DEBUG_OBJECT_PRUNING'})
1512 0 4 if ($all_objects_cache_size > $cache_size_lowwater)
1514 0 0 if ($ENV{'UR_DEBUG_OBJECT_PRUNING'})
1524 0 45 unless ref $obj_list eq 'ARRAY'
1544 0 0 unless defined $max_show
1556 0 0 if ($ENV{'UR_DEBUG_OBJECT_PRUNING'} > 1)
1565 0 0 unless $obj
1568 0 0 unless ($class_data_source)
1572 0 0 unless (exists $obj->{'__get_serial'})
1576 0 0 if (exists $obj->{'__strengthened'})
1580 0 0 if ($obj->__changes__)
1584 0 0 if ($is_prunable)
1600 0 329 unless ($saved)
1613 71 159 if $obj->{'__defined'}
1626 2 16 if (wantarray or not defined wantarray) { }
1634 8 1 if ($return_closure)
1641 36 7 unless (defined $next[$i])
1644 16 20 unless (defined $next[$i])
1648 6 10 if $i < @results
1656 3 6 if ($cmp > 0) { }
2 4 elsif ($cmp == 0) { }
1674 0 2 $plast == $_ ? :
1676 0 1 unless defined wantarray
1677 1 0 if wantarray
1678 0 0 if (@results > 1)
1697 149923 194150 if (ref $self and not defined $load)
1701 2 344071 if ($group_by and $rule_template->order_by)
1704 1 1 unless ($group_by{$order_by_property})
1710 40 344032 if ($cache_size_highwater and $all_objects_cache_size > $cache_size_highwater)
1718 9 344063 if ($rule_template->isa('UR::BoolExpr::Template::Or'))
1733 35 0 if ($subclassify_by and not $meta->is_abstract and not $rule->template->group_by and not $rule->specifies_value_for($subclassify_by))
1746 269483 74580 if (not defined $load or $load)
1748 265594 3889 if (not $ds or $class =~ /::Ghost$/)
1768 0 344063 if $is_monitor_query
1771 3726 340337 unless (defined $load)
1775 1863 1863 $cache_is_complete ? :
1778 100 3803 if ($ds and $load and $rule_template->order_by)
1783 3 97 if ($qp->order_by_non_column_data)
1784 0 3 if $is_monitor_query
1793 342015 25 unless ($load or $return_closure)
1797 91583 172315 unless (exists $_->{'__get_serial'})
1807 0 342015 if ($is_monitor_query)
1813 13 342002 if (defined $normalized_rule_template->limit or defined $normalized_rule_template->offset)
1817 69693 272322 if wantarray
1818 1 272321 unless defined wantarray
1819 1 272320 if @c > 1
1828 0 2048 if ($cached) { }
1834 0 2048 if $is_monitor_query
1836 6 1168 unless (exists $_->{'__get_serial'})
1849 2023 25 if ($load)
1852 0 2023 if $is_monitor_query
1857 78 1947 if ($return_closure) { }
1858 53 25 if ($load) { }
1864 3 22 if (defined $normalized_rule_template->limit or defined $normalized_rule_template->offset)
1872 1947 0 if ($loading_iterator) { }
1881 0 0 if (defined $normalized_rule_template->limit or defined $normalized_rule_template->offset)
1886 261 1671 unless defined wantarray
1887 1159 512 if wantarray
1888 1 511 if (@results > 1)
1904 0 1 if (@$resultsref > 10)
1914 10 6 defined $tmpl->limit ? :
1917 1 15 if ($offset > @$obj_list) { }
1929 23 1264 unless (defined $pending_db_object_data)
1931 2 21 if (defined $existing_object and $self->object_exists_in_underlying_context($existing_object) and $existing_object->__changes__) { }
1947 23 1241 if (exists $existing_object->{'db_saved_uncommitted'}) { }
1241 0 elsif (exists $existing_object->{'db_committed'}) { }
1965 0 3677 unless exists $existing_object->{$property}
1971 42 3635 if ($object_value ne $expected_db_value)
1976 3665 12 if ($object_value eq $db_value or $object_value eq $expected_db_value or $db_value eq $expected_db_value) { }
1990 12 1252 if (defined $conflict)
1998 12 0 defined $old_dbc{$conflict} ? :
2001 12 0 defined $pending_db_object_data->{$conflict} ? :
2004 12 0 defined $existing_object->{$conflict} ? :
2018 1223 29 unless ($different)
2029 3549 22 if $existing_object->{$property} eq $pending_db_object_data->{$property}
2052 0 4 unless defined $id_list and @$id_list
2075 33 3693 if ref $id and ref $id eq 'HASH'
2076 1185 2541 if ($id_only) { }
29 2512 elsif ($params->{'_unique'}) { }
2080 27 1158 if (ref $id) { }
2092 9 18 if (@objects == @$id) { }
2108 554 604 if (exists $UR::Context::all_objects_loaded->{$class}{$id}) { }
508 96 elsif (not $class->isa('UR::Value')) { }
2123 0 508 if (@objects)
2137 0 29 if (@objects)
2142 563 3163 if ($cache_is_complete)
2147 563 0 wantarray ? :
2162 8 3155 if $loading_is_in_progress_on_another_iterator
2180 1300 1855 if ($object_is_loaded_or_non_existent) { }
2221 334750 9371 unless ($strategy)
2222 29 334721 if ($rule->template->group_by) { }
489 334232 elsif ($rule->num_values == 0) { }
269368 64864 elsif ($rule->is_id_only) { }
2238 503 343618 if ($strategy eq 'all') { }
278660 64958 elsif ($strategy eq 'id') { }
64929 29 elsif ($strategy eq 'index') { }
29 0 elsif ($strategy eq 'set intersection') { }
2244 0 278660 unless (defined $id)
2254 58 278602 if (ref $id eq 'ARRAY') { }
2259 39 19 if @matches == @$id
2263 0 278602 unless (defined $id)
2272 45653 232949 if (not $UR::Object::Type::bootstrapping and $class eq 'UR::Object::Type')
2277 38860 6793 if ($match) { }
2287 68124 164825 if $match
2295 157788 7056 unless @subclasses_loaded
2297 0 7056 if (ref $id eq 'ARRAY') { }
2310 6569 70112 if $match
2326 224 114373 if (substr($key, 0, 1) eq '-' or substr($key, 0, 1) eq '_') { }
27 114346 elsif ($key =~ /^\w*\./) { }
2338 121 95078 if ($prop_meta and $prop_meta->is_many || $prop_meta->is_delegated)
2349 201 64728 unless (@properties)
2356 0 64728 unless (@properties == @values)
2374 0 64728 if ($UR::Debug::verify_indexes)
2378 0 0 unless (join($", @matches) eq join($", @matches2))
2389 24 64704 if ($should_evaluate_later) { }
2416 40 60 if ($bxt->id ne $expected_template_id) { }
20 40 elsif (not $bx->is_subset_of($rule_no_group)) { }
2451 0 344121 if $@
2453 45 344076 if (my $recurse = $template->recursion_desc)
2459 13 32 if (@values)
2474 16036 328085 if (@results > 1)
2476 5 16031 if ($group_by) { }
2489 344121 0 if wantarray
2490 0 0 if @results > 1
2507 16 3 if (@values) { }
2516 19 26 if $seen{$bx->id}++
2529 0 1990 if (exists $$all_params_loaded{$template->id} and exists $$all_params_loaded{$template->id}{$rule->id})
2535 107 1883 if ($template->subject_class_name->isa('UR::Value'))
2548 628 6723 if ($template->is_subset_of($loaded_template))
2560 130 10 if $rule->is_subset_of($loaded_rule)
2580 0 0 unless @_
2588 0 337010 unless (ref $self)
2591 0 337010 if (@_)
2605 0 52 unless @_
2608 47 5 unless ref $self
2612 3 45 unless ($self->_sync_databases)
2620 0 45 unless ($self->_commit_databases)
2637 0 15 unless ($self)
2643 0 15 unless ($self->_reverse_all_changes)
2647 0 15 unless ($self->_rollback_databases)
2657 3 0 if (ref $self) { }
2672 0 3 if ($args{'dont_unload'})
2686 0 287 if $class_name eq 'UR::Command::Param'
2687 30 257 if $class_name->isa('UR::Singleton')
2703 24 233 unless $class_obj->is_uncachable
2704 6 227 if $class_obj->is_meta_meta
2705 12 215 unless $class_obj->is_transactional
2708 0 215 if $local_dont_unload{$class_name} or grep {$class_name->isa($_);} @{$args{'dont_unload'};}
2710 139 76 if $class_obj->is_meta
2712 46 30 unless defined $class_obj->data_source
2723 0 18 if $local_dont_unload{$obj_type} or grep {$obj_type->isa($_);} @{$args{'dont_unload'};}
2727 3 27 if (@obj)
2732 0 3 if (my(@changed) = grep({$_->__changes__;} @obj))
2757 54 188 $_->isa('UR::DataSource::Default') ? :
2765 0 69 unless $is_default{$a->id} <=> $is_default{$b->id} or $can_savepoint{$a->id} <=> $can_savepoint{$b->id}
2781 0 54 if $IS_SYNCING_DATABASE
2783 0 54 if ($App::DB::{'sync_database'})
2784 0 0 unless ('App::DB'->sync_database)
2793 0 54 if (@o)
2805 0 54 unless @changed_objects
2811 1 53 if (@invalid)
2821 280 147 unless $data_source
2841 50 2 if ($result) { }
2861 0 3 if ($App::DB::{'rollback'})
2886 0 4 if ($nr_of_lines > 40) { }
2905 1 14 if (ref $self) { }
2938 0 45 if $IS_COMMITTING_DATABASE
2940 0 45 if ($App::DB::{'commit'})
2941 0 0 unless ('App::DB'->commit)
2952 166 0 if ($ds->commit) { }
2956 0 0 if (@committed)
2975 0 15 if $IS_ROLLINGBACK_DATABASE
2977 0 15 if ($App::DB::{'rollback'})
2978 0 0 unless ('App::DB'->rollback)
2986 0 15 unless $class->_for_each_data_source('rollback')
3002 0 29 unless ($ds->$method)
3015 5 0 if ($object->{'db_committed'}) { }
0 0 elsif ($object->{'db_saved_uncommitted'}) { }
3031 0 0 if (my $filename = $params{'filename'}) { }
3034 0 0 unless ($fh)
3056 44 92 if (ref $class)
3058 0 44 if (@_)
3068 0 136 if (@extra)
3069 0 0 if (scalar @extra == 2 and $extra[0] eq 'sql' || $extra[0] eq 'sql in') { }