Showing 2 changed files with 14 additions and 35 deletions
+14 -28
lib/DBIx/Custom.pm
... ...
@@ -1,6 +1,6 @@
1 1
 package DBIx::Custom;
2 2
 
3
-our $VERSION = '0.1666';
3
+our $VERSION = '0.1667';
4 4
 
5 5
 use 5.008001;
6 6
 use strict;
... ...
@@ -783,8 +783,7 @@ sub register_filter {
783 783
 sub register_tag { shift->query_builder->register_tag(@_) }
784 784
 
785 785
 our %SELECT_ARGS
786
-  = map { $_ => 1 } @COMMON_ARGS, qw/column where append relation
787
-                                     selection join/;
786
+  = map { $_ => 1 } @COMMON_ARGS, qw/column where append relation join/;
788 787
 
789 788
 sub select {
790 789
     my ($self, %args) = @_;
... ...
@@ -801,7 +800,6 @@ sub select {
801 800
                : defined $table ? [$table]
802 801
                : [];
803 802
     my $columns   = delete $args{column};
804
-    my $selection = delete $args{selection} || '';
805 803
     my $where     = delete $args{where} || {};
806 804
     my $append    = delete $args{append};
807 805
     my $join      = delete $args{join} || [];
... ...
@@ -816,17 +814,7 @@ sub select {
816 814
     my @sql;
817 815
     push @sql, 'select';
818 816
     
819
-    # Selection
820
-    if ($selection) { 
821
-        push @sql, $selection;
822
-        if ($selection =~ /from\s+(?:\{table\s+)?([^\s\{]+?)\b/) {
823
-             unshift @$tables, $1;
824
-        }
825
-        unshift @$tables, @{$self->_tables($selection)};
826
-    }
827
-    
828
-    # Column clause
829
-    elsif ($columns) {
817
+    if ($columns) {
830 818
 
831 819
         $columns = [$columns] if ! ref $columns;
832 820
         
... ...
@@ -884,21 +872,19 @@ sub select {
884 872
     else { push @sql, '*' }
885 873
     
886 874
     # Table
887
-    unless ($selection) {
888
-        push @sql, 'from';
889
-        if ($relation) {
890
-            my $found = {};
891
-            foreach my $table (@$tables) {
892
-                push @sql, ($table, ',') unless $found->{$table};
893
-                $found->{$table} = 1;
894
-            }
895
-        }
896
-        else {
897
-            my $main_table = $tables->[-1] || '';
898
-            push @sql, $main_table;
875
+    push @sql, 'from';
876
+    if ($relation) {
877
+        my $found = {};
878
+        foreach my $table (@$tables) {
879
+            push @sql, ($table, ',') unless $found->{$table};
880
+            $found->{$table} = 1;
899 881
         }
900
-        pop @sql if ($sql[-1] || '') eq ',';
901 882
     }
883
+    else {
884
+        my $main_table = $tables->[-1] || '';
885
+        push @sql, $main_table;
886
+    }
887
+    pop @sql if ($sql[-1] || '') eq ',';
902 888
     
903 889
     # Main table
904 890
     croak "Not found table name" unless $tables->[-1];
-7
t/dbix-custom-core-sqlite.t
... ...
@@ -1340,13 +1340,6 @@ $result = $dbi->select(
1340 1340
 );
1341 1341
 is($result->fetch_first->[0], 'B');
1342 1342
 
1343
-test 'selection';
1344
-$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1345
-$dbi->execute($CREATE_TABLE->{0});
1346
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1347
-$result = $dbi->select(selection => '* from {table table1}', where => {key1 => 1});
1348
-is_deeply($result->fetch_hash_all, [{key1 => 1, key2 => 2}]);
1349
-
1350 1343
 test 'Model class';
1351 1344
 use MyDBI1;
1352 1345
 $dbi = MyDBI1->connect($NEW_ARGS->{0});