Merged how insert and update set columns
[dbsrgits/SQL-Abstract-2.0-ish.git] / lib / SQL / Abstract / Manual / Specification.pod
index 950e0ec..b10ce18 100644 (file)
@@ -189,13 +189,10 @@ The hash will be structured as follows:
 
   {
       type     => 'Identifier',
-      element1 => Scalar,
-      element2 => Scalar,
-      element3 => Scalar,
+      elements => [ Scalar ],
   }
 
-If element3 exists, then element2 must exist. element1 must always exist. If a
-given element exists, then it must be defined and of non-zero length.
+All values in elements must be defined.
 
 Visitors are expected to, by default, quote all identifiers according to the SQL
 dialect's quoting scheme.
@@ -292,6 +289,19 @@ impossible.
 
 Subqueries, when expressed in SQL, must be bounded by parentheses.
 
+=head3 Alias
+
+An Alias is any place where the construct "X as Y" appears. While the "as Y" is
+often optional, the AST will make it required.
+
+The hash will be structured as follows:
+
+  {
+      type  => 'Alias',
+      value => Expression,
+      as    => Identifier,
+  }
+
 =head3 Expression
 
 An Expression can be any one of the following:
@@ -306,6 +316,8 @@ An Expression can be any one of the following:
 
 =item * Subquery
 
+=item * Alias
+
 =back
 
 An Expression is a meta-syntactic unit. An "Expression" unit will never appear
@@ -328,7 +340,7 @@ The following clauses are expected to be handled by Visitors for each statement:
 
 =over 4
 
-=item * SELECT
+=item * select
 
 =over 4
 
@@ -350,9 +362,7 @@ The following clauses are expected to be handled by Visitors for each statement:
 
 =item * tables
 
-=item * columns
-
-=item * values
+=item * set
 
 =back
 
@@ -389,18 +399,7 @@ The expected clauses are (name and structure):
 
 This corresponds to the SELECT clause of a SELECT statement.
 
-A select clause unit is an array of one or more SelectComponent units.
-
-The hash for a SelectComponent unit is composed as follows:
-
-  {
-      type  => 'SelectComponent',
-      value => Expression,
-      as    => String,
-  }
-
-The 'as' component is optional. Visitors may choose to make it required in
-certain situations.
+A select clause unit is an array of one or more Expressions.
 
 =head3 tables
 
@@ -413,26 +412,7 @@ The tables clause has several RDBMS-specific variations. The AST will support
 all of them and it is up to the Visitor object constructing the actual SQL to
 validate and/or use what is provided as appropriate.
 
-A TableJoin is a junction of the following elements:
-
-=over 4
-
-=item * TableIdentifier
-
-=item * Operator
-
-=back
-
-The hash for a TableIdentifier will be composed as follows:
-
-  # TableIdentifier
-  {
-      type  => 'TableIdentifier',
-      value => Expression,
-      as    => String,
-  }
-
-The value should be either an Identifier or a SubQuery. 
+A tables clause is an Expression.
 
 The hash for an Operator within a tables clause will be composed as follows:
 
@@ -441,6 +421,7 @@ The hash for an Operator within a tables clause will be composed as follows:
       type => 'Operator',
       op   => '< LEFT|RIGHT|FULL [ OUTER ] > | INNER | CROSS',
       on   => Expression,
+      args => [ Expression ],
   }
 
 A USING clause is syntactic sugar for an ON clause and, as such, is not provided
@@ -457,30 +438,20 @@ A where clause is composed of an Expression.
 
 This corresponds to the SET clause in an INSERT or UPDATE statement.
 
-A set clause unit is an array of one or more SetComponent units.
-
-The hash for SetComponent unit is composed as follows:
+The hash for an set clause will be composed as follows:
 
   {
-      type  => 'SetComponent',
-      col   => Identifier,
-      value => Expression,
+      type => 'Set',
+      args => [
+          [ Identifier ],
+          [ Expresion ],
+      ],
   }
 
-=head3 columns
-
-This corresponds to the optional list of columns in an INSERT statement.
-
-A columns clause unit is an array of one or more Identifier units.
-
-=head3 values
-
-This corresponds to the VALUES clause in an INSERT statement.
-
-A values clause unit is an array of one or more Expression units.
-
-If there is a columns clause, the number of entries in the values clause must be
-equal to the number of entries in the columns clause.
+The args is an array that is organized as follows: The first element is an array of
+Identifiers for the columns being set. The following arrays are Expressions describing
+the values. The various arrays should be the same length. The array of Identifiers can
+be omitted.
 
 =head3 orderby
 
@@ -577,8 +548,20 @@ Both the start_with and order_siblings clauses are optional.
 
 =item * sproc unit
 
+=item * UNION, UNION ALL, and MINUS
+
+=item * INSERT INTO <table> SELECT ...
+
+=item * INSERT INTO <table> SET ...
+
+=item * UPDATE foo me SET bar = 1 FROM fnord f WHERE me.col1 = f.frobinator
+
+=item * INSERT moves to using the SET terminology with Visitor dwimming
+
 =back
 
+Convert INSERT and UPDATE into ->populate form.
+
 =head1 AUTHORS
 
 robkinyon: Rob Kinyon C<< <rkinyon@cpan.org> >>