Re-work SELECT
[dbsrgits/SQL-Abstract-2.0-ish.git] / t / 201_select.t
index 61b57d0..e3b3aab 100644 (file)
@@ -19,31 +19,32 @@ is $sqla->dispatch(
 ), "SELECT me.id, me.foo_id AS foo FROM foo AS me",
    "simple select clause";
 
-__END__
 is $sqla->dispatch(
   { -type => 'select',
-    tablespec => {-type => 'alias', ident => {-type => 'name', args => [qw/foo/]}, as => 'me' },
     columns => [
       { -type => 'name', args => [qw/me id/] },
       { -type => 'alias', ident => { -type => 'name', args => [qw/me foo_id/] }, as => 'foo' },
       { -type => 'name', args => [qw/bar name/] },
-    ]
+    ],
+    tablespec => {
+      -type => 'join',
+      args => [ 
+        {-type => 'alias', ident => {-type => 'name', args => [qw/foo/]}, as => 'me' },
+        {-type => 'name', args => [qw/bar/] },
+      ],
+      on => {
+        -type => 'expr',
+        op => '==',
+        args => [
+          {-type => 'name', args => [qw/bar id/]}, 
+          {-type => 'name', args => [qw/me bar_id/]}
+        ],
+      }
+    },
   }
 
 
-  { -type => 'select',
-    from => [-alias => [-name => 'foo'] => 'me' ],
-    columns => [ -list => 
-        [ -name => qw/me id/ ],
-        [ -alias => [ -name => qw/me foo_id/ ], 'foo' ],
-        [ -name => qw/bar name/ ],
-    ],
-    join => {
-      tablespec => [-name => qw/bar/],
-      on => [ '==', [-name => qw/bar id/], [ -name => qw/me bar_id/ ] ],
-    }
-  }
 ), "SELECT me.id, me.foo_id AS foo, bar.name FROM foo AS me JOIN bar ON (bar.id = me.bar_id)", 
    "select with join clause";
 
-
+__END__