Added a nested example and the Nesting type
Rob Kinyon [Thu, 26 Mar 2009 02:36:51 +0000 (22:36 -0400)]
lib/SQL/Abstract/Manual/Examples.pod
lib/SQL/Abstract/Manual/Specification.pod

index d6f3caa..c684127 100644 (file)
@@ -120,9 +120,8 @@ one. The SQL used is from the MySQL dialect.
           {
               type  => 'SelectComponent',
               value => {
-                  type     => 'Value',
-                  subtype => 'number',
-                  value   => 1,
+                  type     => 'Identifier',
+                  element1 => '*',
               },
           },
       ],
@@ -147,9 +146,94 @@ one. The SQL used is from the MySQL dialect.
                   element1 => 'John',
               },
           ],
-      }
+      },
   }
 
+=item SELECT COUNT(*) FROM foo WHERE name = 'John' AND ( title = 'Mr' OR abbrev = 'Dr' )
+
+  {
+      type => 'select',
+      ast_version => 0.0001,
+      select => [
+          {
+              type  => 'SelectComponent',
+              value => {
+                  type     => 'Identifier',
+                  element1 => '*',
+              },
+          },
+      ],
+      tables => {
+          type => 'TableIdentifier',
+          value => {
+              type => 'Identifier',
+              element1 => 'foo',
+          },
+      },
+      where => {
+          type => 'Operator',
+          op   => 'AND',
+          args => [
+              {
+                  type => 'Operator',
+                  op   => '=',
+                  args => [
+                      {
+                          type     => 'Identifier',
+                          element1 => 'name',
+                      },
+                      {
+                          type     => 'Value',
+                          subtype  => 'String',
+                          element1 => 'John',
+                      },
+                  ],
+              },
+              {
+                  type => 'Nesting',
+                  args => [
+                      {
+                          type => 'Operator',
+                          op   => 'OR',
+                          args => [
+                              {
+                                  type => 'Operator',
+                                  op   => '=',
+                                  args => [
+                                      {
+                                          type     => 'Identifier',
+                                          element1 => 'title',
+                                      },
+                                      {
+                                          type     => 'Value',
+                                          subtype  => 'String',
+                                          element1 => 'Mr',
+                                      },
+                                  ],
+                              },
+                              {
+                                  type => 'Operator',
+                                  op   => '=',
+                                  args => [
+                                      {
+                                          type     => 'Identifier',
+                                          element1 => 'abbrev',
+                                      },
+                                      {
+                                          type     => 'Value',
+                                          subtype  => 'String',
+                                          element1 => 'Dr',
+                                      },
+                                  ],
+                              },
+                          ],
+                      },
+                  ],
+              },
+          ],
+      },
+  }
 =back
 
 =head1 AUTHORS
index ed58414..23ea0b1 100644 (file)
@@ -200,6 +200,9 @@ given element exists, then it must be defined and of non-zero length.
 Visitors are expected to, by default, quote all identifiers according to the SQL
 dialect's quoting scheme.
 
+Any of the elements may be '*', as in SELECT * or SELECT COUNT(*). Visitors must
+be careful to I<not> quote asterisks.
+
 =head3 Value
 
 A Value is a Perl scalar. Depending on the type, a Visitor may be able to make
@@ -322,6 +325,17 @@ The hash for an ExpressionList is as follows:
 
 An ExpressionList is always rendered in SQL with parentheses around it.
 
+=head3 Nesting
+
+A Nesting is, essentially, another set of parentheses.
+
+The hash for a Nesting is as follows:
+
+  {
+      type => 'Nesting',
+      args => Array of Expressions,
+  }
+
 =head2 SQL clauses
 
 These are all the legal and acceptable clauses within the AST that would