From: Rob Kinyon Date: Sun, 29 Mar 2009 02:20:10 +0000 (-0400) Subject: Added example and fleshed out ORDER BY and GROUP BY. This finishes all mandatory... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=da74c1c81c68d906ca6c267385c9740977d6ae0f;hp=00a0470ec43ab74e0ef679410e24f9d1a8abc58e;p=dbsrgits%2FSQL-Abstract-2.0-ish.git Added example and fleshed out ORDER BY and GROUP BY. This finishes all mandatory clauses for SELECT statements. --- diff --git a/lib/SQL/Abstract/Manual/Examples.pod b/lib/SQL/Abstract/Manual/Examples.pod index 93fd4cc..a9760be 100644 --- a/lib/SQL/Abstract/Manual/Examples.pod +++ b/lib/SQL/Abstract/Manual/Examples.pod @@ -327,6 +327,84 @@ one. The SQL used is from the MySQL dialect. }, } +=item * SELECT foo, bar baz FROM foo ORDER BY bar, baz DESC GROUP BY 1,3,2 + + { + type => 'select', + ast_version => 0.0001, + select => [ + { + type => 'SelectComponent', + value => { + type => 'Identifier', + element1 => 'foo', + }, + }, + { + type => 'SelectComponent', + value => { + type => 'Identifier', + elements => 'bar', + }, + }, + { + type => 'SelectComponent', + value => { + type => 'Identifier', + element1 => 'baz', + }, + }, + ], + tables => { + type => 'TableIdentifier', + value => { + type => 'Identifier', + element1 => 'foo', + }, + }, + orderby => [ + { + type => 'OrderbyComponent', + value => { + type => 'Identifier', + element1 => 'bar', + }, + dir => 'ASC', + }, + { + type => 'OrderbyComponent', + value => { + type => 'Identifier', + element1 => 'baz', + }, + dir => 'DESC', + }, + ], + groupby => [ + { + type => 'GroupbyComponent', + value => { + type => 'Number', + value => 1, + }, + }, + { + type => 'GroupbyComponent', + value => { + type => 'Number', + value => 3, + }, + }, + { + type => 'GroupbyComponent', + value => { + type => 'Number', + value => 2, + }, + }, + ], + } + =back =head1 AUTHORS diff --git a/lib/SQL/Abstract/Manual/Specification.pod b/lib/SQL/Abstract/Manual/Specification.pod index 4c2cb52..32281db 100644 --- a/lib/SQL/Abstract/Manual/Specification.pod +++ b/lib/SQL/Abstract/Manual/Specification.pod @@ -427,8 +427,8 @@ The hash for an Operator within a tables clause will be composed as follows: } A USING clause is syntactic sugar for an ON clause and, as such, is not provided -for by the AST. A join of a comma is identical to a CROSS JOIN. The on clause is -optional. +for by the AST. A join of a comma is identical to a CROSS JOIN and, as such, is +not provided for by the AST. The on clause is optional. =head3 where @@ -461,7 +461,7 @@ A columns clause is an IdentifierList and the unit is composed as follows: This corresponds to the VALUES clause in an INSERT statement. -A values clause is an ExpressionList and the unit is composed as follows. +A values clause is an ExpressionList and the unit is composed as follows: values => [ Expression, @@ -475,23 +475,33 @@ equal to the number of entries in the columns clause. This corresponds to the ORDER BY clause in a SELECT statement. -An orderby clause is composed as follows: +A orderby clause unit is an array of one or more OrderbyComponent units. - OrderByComponent := XXX-TODO-XXX - OrderByDirection := ASC | DESC +The hash for a OrderbyComponent unit is composed as follows: - OrderByComponent [ OrderByDirection ] - [ , OrderByComponent [ OrderByDirection ] ]* + { + type => 'OrderbyComponent', + value => < Identifier | Number > + dir => '< ASC | DESC >', + } + +The dir element, if omitted, will be defaulted to ASC by the AST. The number +corresponds to a column in the select clause. =head3 groupby This corresponds to the GROUP BY clause in a SELECT statement. -An groupby clause is composed as follows: +A groupby clause unit is an array of one or more GroupbyComponent units. - GroupByComponent := XXX-TODO-XXX +The hash for a GroupbyComponent unit is composed as follows: + + { + type => 'GroupbyComponent', + value => < Identifier | Number > + } - GroupByComponent [ , GroupByComponent ]* +The number corresponds to a column in the select clause. =head3 rows