[Bast-commits] r8163 - in DBIx-Class/0.08/trunk: . lib/DBIx/Class/Storage t

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Thu Dec 24 08:59:53 GMT 2009


Author: ribasushi
Date: 2009-12-24 08:59:52 +0000 (Thu, 24 Dec 2009)
New Revision: 8163

Modified:
   DBIx-Class/0.08/trunk/Changes
   DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
   DBIx-Class/0.08/trunk/t/86sqlt.t
Log:
Fix deployment_statements context sensitivity regression

Modified: DBIx-Class/0.08/trunk/Changes
===================================================================
--- DBIx-Class/0.08/trunk/Changes	2009-12-24 06:50:16 UTC (rev 8162)
+++ DBIx-Class/0.08/trunk/Changes	2009-12-24 08:59:52 UTC (rev 8163)
@@ -8,6 +8,7 @@
         - Views without a view_definition will throw an exception when
           parsed by SQL::Translator::Parser::DBIx::Class
         - Schema POD improvement for dclone
+        - Fix regression in context sensitiveness of deployment_statements
 
 0.08115 2009-12-10 09:02:00 (CST)
         - Real limit/offset support for MSSQL server (via Row_Number)

Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm	2009-12-24 06:50:16 UTC (rev 8162)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm	2009-12-24 08:59:52 UTC (rev 8163)
@@ -2373,10 +2373,19 @@
     data => $schema,
   );
 
-  my $ret = $tr->translate
-    or $self->throw_exception( 'Unable to produce deployment statements: ' . $tr->error);
+  my @ret;
+  my $wa = wantarray;
+  if ($wa) {
+    @ret = $tr->translate;
+  }
+  else {
+    $ret[0] = $tr->translate;
+  }
 
-  return $ret;
+  $self->throw_exception( 'Unable to produce deployment statements: ' . $tr->error)
+    unless (@ret && defined $ret[0]);
+
+  return $wa ? @ret : $ret[0];
 }
 
 sub deploy {

Modified: DBIx-Class/0.08/trunk/t/86sqlt.t
===================================================================
--- DBIx-Class/0.08/trunk/t/86sqlt.t	2009-12-24 06:50:16 UTC (rev 8162)
+++ DBIx-Class/0.08/trunk/t/86sqlt.t	2009-12-24 08:59:52 UTC (rev 8163)
@@ -14,6 +14,36 @@
 
 my $schema = DBICTest->init_schema (no_deploy => 1);
 
+
+# Check deployment statements ctx sensitivity
+{
+  my $not_first_table_creation_re = qr/CREATE TABLE fourkeys_to_twokeys/;
+
+
+  my $statements = $schema->deployment_statements;
+  like (
+    $statements,
+    $not_first_table_creation_re,
+    'All create statements returned in 1 string in scalar ctx'
+  );
+
+  my @statements = $schema->deployment_statements;
+  cmp_ok (scalar @statements, '>', 1, 'Multiple statement lines in array ctx');
+
+  my $i = 0;
+  while ($i <= $#statements) {
+    last if $statements[$i] =~ $not_first_table_creation_re;
+    $i++;
+  }
+
+  ok (
+    ($i > 0) && ($i <= $#statements),
+    "Creation statement was found somewherere within array ($i)"
+  );
+}
+
+
+
 # replace the sqlt calback with a custom version ading an index
 $schema->source('Track')->sqlt_deploy_callback(sub {
   my ($self, $sqlt_table) = @_;




More information about the Bast-commits mailing list