cvsuser     04/02/18 05:17:40

  Modified:    App-Repository/lib/App/Repository DBI.pm
               App-Repository/t DBI-select.t
  Log:
  added 'verbatim' op to params
  
  Revision  Changes    Path
  1.17      +13 -2     p5ee/App-Repository/lib/App/Repository/DBI.pm
  
  Index: DBI.pm
  ===================================================================
  RCS file: /cvs/public/p5ee/App-Repository/lib/App/Repository/DBI.pm,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -w -r1.16 -r1.17
  --- DBI.pm    3 Feb 2004 14:58:41 -0000       1.16
  +++ DBI.pm    18 Feb 2004 13:17:40 -0000      1.17
  @@ -1,13 +1,13 @@
   
   ######################################################################
  -## File: $Id: DBI.pm,v 1.16 2004/02/03 14:58:41 spadkins Exp $
  +## File: $Id: DBI.pm,v 1.17 2004/02/18 13:17:40 spadkins Exp $
   ######################################################################
   
   use App;
   use App::Repository;
   
   package App::Repository::DBI;
  -$VERSION = do { my @r=(q$Revision: 1.16 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r};
  +$VERSION = do { my @r=(q$Revision: 1.17 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r};
   
   @ISA = ( "App::Repository" );
   
  @@ -534,6 +534,12 @@
                       $sqlop = $sqlop{$repop};
                   }
               }
  +
  +            if ($repop eq "verbatim") {
  +                $where .= ($colnum == 0) ? "where $params->{$param}\n" : "  and 
$params->{$param}\n";
  +                next;
  +            }
  +
               $column_def = $tabcols->{$column};
   
               if (!defined $column_def) {
  @@ -964,6 +970,11 @@
                   $column = $1;
                   $sqlop = $sqlop{$repop};
               }
  +        }
  +
  +        if ($repop eq "verbatim") {
  +            push(@criteria_conditions, $params->{$param});
  +            next;
           }
   
           $column_def = $table_def->{column}{$column};
  
  
  
  1.5       +36 -0     p5ee/App-Repository/t/DBI-select.t
  
  Index: DBI-select.t
  ===================================================================
  RCS file: /cvs/public/p5ee/App-Repository/t/DBI-select.t,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -w -r1.4 -r1.5
  --- DBI-select.t      18 Nov 2003 21:38:10 -0000      1.4
  +++ DBI-select.t      18 Feb 2004 13:17:40 -0000      1.5
  @@ -445,6 +445,22 @@
   is($sql, $expect_sql, "_mk_select_sql(): ordercols, directions");
   &check_select($sql,0);
   
  +$expect_sql = <<EOF;
  +select
  +   first_name,
  +   last_name,
  +   city,
  +   state,
  +   age
  +from test_person
  +where age in (14,15,16,17,18)
  +EOF
  +$sql = $rep->_mk_select_sql("test_person",
  +                            {"age.verbatim" => "age in (14,15,16,17,18)"},
  +                            ["first_name","last_name","city","state","age"]);
  +is($sql, $expect_sql, "_mk_select_sql(): verbatim");
  +&check_select($sql,0);
  +
   ###########################################################################
   # JOINED (MULTI-TABLE) SELECT SQL-GENERATION TESTS
   ###########################################################################
  @@ -776,6 +792,26 @@
       "test_person",{},["first_name","last_name","city","state","age"],
       {ordercols=>["last_name","city","address","gender","first_name"],
        directions=>{last_name=>"ASC",city=>"",address=>undef,gender=>"Desc"}});
  +
  +$expect_sql = <<EOF;
  +select
  +   t1.first_name,
  +   t1.last_name,
  +   t1.city,
  +   t1.state,
  +   t1.age
  +from test_person
  +where age in (14,15,16,17,18)
  +EOF
  +&test_get_rows($expect_sql, 0, "_mk_select_joined_sql(): ordercols, directions",
  +    "test_person",
  +    {"age.verbatim" => "age in (14,15,16,17,18)"},
  +    ["first_name","last_name","city","state","age"]);
  +$sql = $rep->_mk_select_sql("test_person",
  +                            {"age.verbatim" => "age in (14,15,16,17,18)"},
  +                            ["first_name","last_name","city","state","age"]);
  +is($sql, $expect_sql, "_mk_select_sql(): verbatim");
  +&check_select($sql,0);
   
   exit 0;
   
  
  
  

Reply via email to