Make join tests behave
[dbsrgits/SQL-Abstract-2.0-ish.git] / t / 200_join.t
index 7cf9be8..9ba74b6 100644 (file)
@@ -8,31 +8,34 @@ use_ok('SQL::Abstract') or BAIL_OUT( "$@" );
 
 my $sqla = SQL::Abstract->create(1);
 
+my $foo = {-type => name => args => [qw/foo/]};
+my $bar = {-type => name => args => [qw/bar/]},
+my $fnord = {-type => name => args => [qw/fnord/]};
+
+my $foo_id = { -type => 'name', args => [qw/foo id/] };
+my $me_foo_id = { -type => 'name', args => [qw/me foo_id/] };
+
 is $sqla->dispatch(
   { -type => 'join',
-    args => [
-      {-type => name => args => [qw/bar/]},
-      {-type => name => args => [qw/foo/]},
-    ],
+    lhs => $bar,
+    rhs => $foo,
     on => { 
       -type => 'expr',
       op => '==',
-      args => [
-        { -type => 'name', args => [qw/foo id/] },
-        { -type => 'name', args => [qw/me foo_id/] },
-      ]
+      args => [ $foo_id, $me_foo_id ]
     }
   }
 ), "bar JOIN foo ON (foo.id = me.foo_id)", 
    "simple join clause";
 
+
+$foo_id = { -type => 'name', args => [qw/foo_id/] };
+
 is $sqla->dispatch(
   { -type => 'join',
-    args => [
-      {-type => name => args => [qw/fnord/]},
-      {-type => 'alias', ident => {-type => name => args => [qw/foo/]}, as => 'bar' }
-    ],
-    using => { -type => 'name', args => [qw/foo_id/] },
+    lhs => $fnord,
+    rhs => {-type => 'alias', ident => $foo, as => 'bar' },
+    using => $foo_id
   }
 ), "fnord JOIN foo AS bar USING (foo_id)", 
    "using join clause";
@@ -41,11 +44,9 @@ is $sqla->dispatch(
 is $sqla->dispatch(
   { -type => 'join',
     join_type => 'LEFT',
-    args => [
-      {-type => name => args => [qw/fnord/]},
-      {-type => 'alias', ident => {-type => name => args => [qw/foo/]}, as => 'bar' }
-    ],
-    using => { -type => 'name', args => [qw/foo_id/] },
+    lhs => $fnord,
+    rhs => {-type => 'alias', ident => $foo, as => 'bar' },
+    using => $foo_id
   }
 ), "fnord LEFT JOIN foo AS bar USING (foo_id)", 
    "using left join clause";