Do not yell loudly on TODOified is_same_* tests
[scpubgit/Q-Branch.git] / lib / SQL / Abstract / Test.pm
index 16631fe..c802be1 100644 (file)
@@ -16,6 +16,8 @@ my $sqlat = SQL::Abstract::Tree->new;
 
 our $case_sensitive = 0;
 our $parenthesis_significant = 0;
+our $order_by_asc_significant = 0;
+
 our $sql_differ; # keeps track of differing portion between SQLs
 our $tb = __PACKAGE__->builder;
 
@@ -80,17 +82,21 @@ sub is_same_bind {
 sub _sql_differ_diag {
   my ($sql1, $sql2) = @_;
 
-  $tb->diag("SQL expressions differ\n"
+  $tb->${\( $tb->in_todo ? 'note' : 'diag')} (
+       "SQL expressions differ\n"
       ."     got: $sql1\n"
       ."expected: $sql2\n"
       ."differing in :\n$sql_differ\n"
-      );
+  );
 }
 
 sub _bind_differ_diag {
   my ($bind_ref1, $bind_ref2) = @_;
 
-  $tb->diag("BIND values differ\n"
+  local $Data::Dumper::Maxdepth;
+
+  $tb->${\( $tb->in_todo ? 'note' : 'diag')} (
+       "BIND values differ\n"
       ."     got: " . Dumper($bind_ref1)
       ."expected: " . Dumper($bind_ref2)
       );
@@ -173,6 +179,11 @@ sub _eq_sql {
       $sqlat->_parenthesis_unroll($_) for $left, $right;
     }
 
+    # unroll ASC order by's
+    unless ($order_by_asc_significant) {
+      $sqlat->_strip_asc_from_order_by($_) for $left, $right;
+    }
+
     if ( $left->[0] ne $right->[0] ) {
       $sql_differ = sprintf "OP [$left->[0]] != [$right->[0]] in\nleft: %s\nright: %s\n",
         $sqlat->unparse($left),
@@ -326,6 +337,11 @@ If true, SQL comparison will preserve and report difference in nested
 parenthesis. Useful while testing C<IN (( x ))> vs C<IN ( x )>.
 Defaults to false;
 
+=head2 $order_by_asc_significant
+
+If true SQL comparison will consider C<ORDER BY foo ASC> and
+C<ORDER BY foo> to be different. Default is false;
+
 =head2 $sql_differ
 
 When L</eq_sql> returns false, the global variable