[Bast-commits] r5678 - in SQL-Abstract/1.x/branches/1.50_RC: . lib/SQL t

norbi at dev.catalyst.perl.org norbi at dev.catalyst.perl.org
Tue Mar 3 21:37:12 GMT 2009


Author: norbi
Date: 2009-03-03 21:37:11 +0000 (Tue, 03 Mar 2009)
New Revision: 5678

Modified:
   SQL-Abstract/1.x/branches/1.50_RC/
   SQL-Abstract/1.x/branches/1.50_RC/lib/SQL/Abstract.pm
   SQL-Abstract/1.x/branches/1.50_RC/t/01generate.t
Log:
 r5758 at vger:  mendel | 2009-03-03 20:35:10 +0100
  * Added tests and updated POD for bindtype = 'columns' case in \[$sql, @bind] when column_meta is a reference in the [column_meta => value] format bind values.



Property changes on: SQL-Abstract/1.x/branches/1.50_RC
___________________________________________________________________
Name: svk:merge
   - 4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/SQL-Abstract/1.x/branches/1.50_RC:5619
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/SQL-Abstract/1.x/branches/1.50_RC-extraparens:5308
   + 4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/SQL-Abstract/1.x/branches/1.50_RC:5758
4d5fae46-8e6a-4e08-abee-817e9fb894a2:/local/bast/SQL-Abstract/1.x/branches/1.50_RC-extraparens:5308

Modified: SQL-Abstract/1.x/branches/1.50_RC/lib/SQL/Abstract.pm
===================================================================
--- SQL-Abstract/1.x/branches/1.50_RC/lib/SQL/Abstract.pm	2009-03-03 14:27:57 UTC (rev 5677)
+++ SQL-Abstract/1.x/branches/1.50_RC/lib/SQL/Abstract.pm	2009-03-03 21:37:11 UTC (rev 5678)
@@ -1881,8 +1881,11 @@
 
 Note that you must pass the bind values in the same format as they are returned
 by C</where>. That means that if you set L</bindtype> to C<columns>, you must
-provide the bind values in the C<< [ column_name => value ] >> format, so eg.
-the above example will look like:
+provide the bind values in the C<< [ column_meta => value ] >> format, where
+C<column_meta> is an opaque scalar value; most commonly the column name, but
+you can use any scalar scalar value (including references and blessed
+references), L<SQL::Abstract> will simply pass it through intact. So eg. the
+above example will look like:
 
     my %where = (
        date_column => \[q/= date '2008-09-30' - ?::integer/, [ dummy => 10 ]/]

Modified: SQL-Abstract/1.x/branches/1.50_RC/t/01generate.t
===================================================================
--- SQL-Abstract/1.x/branches/1.50_RC/t/01generate.t	2009-03-03 14:27:57 UTC (rev 5677)
+++ SQL-Abstract/1.x/branches/1.50_RC/t/01generate.t	2009-03-03 21:37:11 UTC (rev 5678)
@@ -483,6 +483,42 @@
               args   => ['test', '*', { a => {-in => \["(SELECT d FROM to_date(?, 'MM/DD/YY') AS d)", '02/02/02']}, b => 8 }],
               exception_like => qr/bindtype 'columns' selected, you need to pass: \[column_name => bind_value\]/,
       },             
+      #53
+      {
+              func   => 'insert',
+              new    => {bindtype => 'columns'},
+              args   => ['test', {a => 1, b => \["to_date(?, 'MM/DD/YY')", [{dummy => 1} => '02/02/02']]}],
+              stmt   => 'INSERT INTO test (a, b) VALUES (?, to_date(?, \'MM/DD/YY\'))',
+              stmt_q => 'INSERT INTO `test` (`a`, `b`) VALUES (?, to_date(?, \'MM/DD/YY\'))',
+              bind   => [[a => '1'], [{dummy => 1} => '02/02/02']],
+      },
+      #54
+      {              
+              func   => 'update',
+              new    => {bindtype => 'columns'},
+              args   => ['test', {a => 1, b => \["to_date(?, 'MM/DD/YY')", [{dummy => 1} => '02/02/02']]}, {a => {'between', [1,2]}}],
+              stmt   => 'UPDATE test SET a = ?, b = to_date(?, \'MM/DD/YY\') WHERE ( a BETWEEN ? AND ? )',
+              stmt_q => 'UPDATE `test` SET `a` = ?, `b` = to_date(?, \'MM/DD/YY\') WHERE ( `a` BETWEEN ? AND ? )',
+              bind   => [[a => '1'], [{dummy => 1} => '02/02/02'], [a => '1'], [a => '2']],
+      },             
+      #55
+      {
+              func   => 'select',
+              new    => {bindtype => 'columns'},
+              args   => ['test', '*', { a => \["= to_date(?, 'MM/DD/YY')", [{dummy => 1} => '02/02/02']]}],
+              stmt   => q{SELECT * FROM test WHERE ( a = to_date(?, 'MM/DD/YY') )},
+              stmt_q => q{SELECT * FROM `test` WHERE ( `a` = to_date(?, 'MM/DD/YY') )},
+              bind   => [[{dummy => 1} => '02/02/02']],
+      },
+      #56
+      {
+              func   => 'select',
+              new    => {bindtype => 'columns'},
+              args   => ['test', '*', { a => {'<' => \["to_date(?, 'MM/DD/YY')", [{dummy => 1} => '02/02/02']]}, b => 8 }],
+              stmt   => 'SELECT * FROM test WHERE ( a < to_date(?, \'MM/DD/YY\') AND b = ? )',
+              stmt_q => 'SELECT * FROM `test` WHERE ( `a` < to_date(?, \'MM/DD/YY\') AND `b` = ? )',
+              bind   => [[{dummy => 1} => '02/02/02'], [b => 8]],
+      },             
 );
 
 




More information about the Bast-commits mailing list