LEFT JOIN + rework join tests
[dbsrgits/SQL-Abstract-2.0-ish.git] / t / 200_join.t
index 7095518..7cf9be8 100644 (file)
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 3;
+use Test::More tests => 4;
 use Test::Differences;
 
 use_ok('SQL::Abstract') or BAIL_OUT( "$@" );
@@ -10,7 +10,10 @@ my $sqla = SQL::Abstract->create(1);
 
 is $sqla->dispatch(
   { -type => 'join',
-    tablespec => {-type => name => args => [qw/foo/]},
+    args => [
+      {-type => name => args => [qw/bar/]},
+      {-type => name => args => [qw/foo/]},
+    ],
     on => { 
       -type => 'expr',
       op => '==',
@@ -20,13 +23,29 @@ is $sqla->dispatch(
       ]
     }
   }
-), "JOIN foo ON (foo.id = me.foo_id)", 
+), "bar JOIN foo ON (foo.id = me.foo_id)", 
    "simple join clause";
 
 is $sqla->dispatch(
   { -type => 'join',
-    tablespec => {-type => 'alias', ident => {-type => name => args => [qw/foo/]}, as => 'bar' },
+    args => [
+      {-type => name => args => [qw/fnord/]},
+      {-type => 'alias', ident => {-type => name => args => [qw/foo/]}, as => 'bar' }
+    ],
     using => { -type => 'name', args => [qw/foo_id/] },
   }
-), "JOIN foo AS bar USING (foo_id)", 
+), "fnord JOIN foo AS bar USING (foo_id)", 
    "using join clause";
+
+
+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/] },
+  }
+), "fnord LEFT JOIN foo AS bar USING (foo_id)", 
+   "using left join clause";