Added skeleton of visitor guidelines and finished further TODO items
[dbsrgits/SQL-Abstract-2.0-ish.git] / lib / SQL / Abstract / Manual / Specification.pod
index b38ef28..f6085c5 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.
@@ -221,15 +218,25 @@ A Number is an unquoted number in some numeric format.
 
 =item * Null
 
-Null is SQL's NULL and corresponds to Perl's C<undef>.
+A Null is SQL's NULL and corresponds to Perl's C<undef>.
 
-=item * BindParameter
+=item * Boolean
 
-This corresponds to a value that will be passed in. This value is normally
-quoted in such a fashion so as to protect against SQL injection attacks. (q.v.
-L<DBI/quote()> for an example.)
+A Boolean is a two-value entity - true or false. Some DBMSes provide an explicit
+boolean while others do not.
 
-BindParameters are normally represented by a '?'.
+=item * Date
+
+A Date represents (generally) a year, month, and day.
+
+=item * Time
+
+A Time represents (generally) an hour, minute, and second.
+
+=item * DateTime
+
+A DateTime represents the complete description necessary to determine a specific point in
+time. This could correspond to a L<DateTime/> object in Perl.
 
 =back
 
@@ -237,14 +244,18 @@ The hash will be structured as follows:
 
   {
       type    => 'Value'
-      subtype => [ 'String' | 'Number' | 'Null' | 'BindParameter' ]
+      subtype => [ 'String' | 'Number' | 'Null' | 'Boolean' | 'Date' | 'Time' | 'DateTime' ]
       value   => Scalar
+      is_bind => Boolean
   }
 
 The provided subtypes are the ones that all Visitors are expected to support.
 Visitors may choose to support additional subtypes. Visitors are expected to
 throw an exception upon encountering an unknown subtype.
 
+C<is_bind> defaults to true. It determines whether or not the Visitor should
+attempt to treat this value as a BindParameter or not.
+
 =head3 Operator
 
 An Operator would be, in SQL dialect terms, a unary operator, a binary operator,
@@ -294,8 +305,7 @@ 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.
+An Alias is any place where the construct "X as Y" appears; it is the "AS Y" part.
 
 The hash will be structured as follows:
 
@@ -343,7 +353,7 @@ The following clauses are expected to be handled by Visitors for each statement:
 
 =over 4
 
-=item * SELECT
+=item * select
 
 =over 4
 
@@ -365,9 +375,7 @@ The following clauses are expected to be handled by Visitors for each statement:
 
 =item * tables
 
-=item * columns
-
-=item * values
+=item * set
 
 =back
 
@@ -417,15 +425,15 @@ 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 tables clause is an Expression.
+A tables clause is an Expression that also allows for Joins.
 
-The hash for an Operator within a tables clause will be composed as follows:
+The hash for an Join within a tables clause will be composed as follows:
 
-  # Operator
   {
-      type => 'Operator',
+      type => 'Join',
       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
@@ -442,30 +450,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
 
@@ -534,28 +532,6 @@ The hash for a for clause is composed as follows:
       value => '< UPDATE | DELETE >',
   }
 
-=head3 connectby
-
-This corresponds to the clause that is used in some RDBMS engines to provide for
-an adjacency-list query.
-
-The hash for a for clause is composed as follows:
-
-  {
-      start_with => [
-          Expression,
-      ],
-      connect_by => {
-          option => '< PRIOR | NOCYCLE >'
-          cond => [
-              Expression,
-          ],
-      },
-      order_siblings => orderby-clause,
-  }
-
-Both the start_with and order_siblings clauses are optional.
-
 =head1 TODO
 
 =over 4
@@ -564,12 +540,12 @@ Both the start_with and order_siblings clauses are optional.
 
 =item * UNION, UNION ALL, and MINUS
 
-=item * INSERT INTO <table> SELECT ...
-
-=item * INSERT INTO <table> SET ...
+=item * start the API guidelines
 
 =back
 
+Convert INSERT and UPDATE into ->populate form.
+
 =head1 AUTHORS
 
 robkinyon: Rob Kinyon C<< <rkinyon@cpan.org> >>