Showing 1 changed files with 21 additions and 19 deletions
+21 -19
lib/DBIx/Custom.pm
... ...
@@ -414,7 +414,10 @@ sub execute {
414 414
     $self->{last_sql} = $query->{sql};
415 415
 
416 416
     # Return query
417
-    return $query if $opt{query};
417
+    if ($opt{query}) {
418
+        delete $param->{$_} for (@cleanup, @{$opt{cleanup} || []});
419
+        return $query;
420
+    };
418 421
     
419 422
     # Merge query filter(DEPRECATED!)
420 423
     $filter ||= $query->{filter} || {};
... ...
@@ -447,26 +450,25 @@ sub execute {
447 450
     
448 451
     # Type rule
449 452
     my $type_filters = {};
450
-    if ($self->{_type_rule_is_called}) {
451
-        unless ($opt{type_rule_off}) {
452
-            my $type_rule_off_parts = {
453
-                1 => $opt{type_rule1_off},
454
-                2 => $opt{type_rule2_off}
455
-            };
456
-            for my $i (1, 2) {
457
-                unless ($type_rule_off_parts->{$i}) {
458
-                    $type_filters->{$i} = {};
459
-                    my $table_alias = $opt{table_alias} || {};
460
-                    for my $alias (keys %$table_alias) {
461
-                        my $table = $table_alias->{$alias};
462
-                        
463
-                        for my $column (keys %{$self->{"_into$i"}{key}{$table} || {}}) {
464
-                            $type_filters->{$i}->{"$alias.$column"} = $self->{"_into$i"}{key}{$table}{$column};
465
-                        }
453
+    my $type_rule_off = !$self->{_type_rule_is_called} || $opt{type_rule_off};
454
+    unless ($type_rule_off) {
455
+        my $type_rule_off_parts = {
456
+            1 => $opt{type_rule1_off},
457
+            2 => $opt{type_rule2_off}
458
+        };
459
+        for my $i (1, 2) {
460
+            unless ($type_rule_off_parts->{$i}) {
461
+                $type_filters->{$i} = {};
462
+                my $table_alias = $opt{table_alias} || {};
463
+                for my $alias (keys %$table_alias) {
464
+                    my $table = $table_alias->{$alias};
465
+                    
466
+                    for my $column (keys %{$self->{"_into$i"}{key}{$table} || {}}) {
467
+                        $type_filters->{$i}->{"$alias.$column"} = $self->{"_into$i"}{key}{$table}{$column};
466 468
                     }
467
-                    $type_filters->{$i} = {%{$type_filters->{$i}}, %{$self->{"_into$i"}{key}{$main_table} || {}}}
468
-                      if $main_table;
469 469
                 }
470
+                $type_filters->{$i} = {%{$type_filters->{$i}}, %{$self->{"_into$i"}{key}{$main_table} || {}}}
471
+                  if $main_table;
470 472
             }
471 473
         }
472 474
     }