From: Rob Kinyon Date: Thu, 26 Mar 2009 02:36:51 +0000 (-0400) Subject: Added a nested example and the Nesting type X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FSQL-Abstract-2.0-ish.git;a=commitdiff_plain;h=4f6e8987a0e5f299e800fa6745c318ea8940d4f4 Added a nested example and the Nesting type --- diff --git a/lib/SQL/Abstract/Manual/Examples.pod b/lib/SQL/Abstract/Manual/Examples.pod index d6f3caa..c684127 100644 --- a/lib/SQL/Abstract/Manual/Examples.pod +++ b/lib/SQL/Abstract/Manual/Examples.pod @@ -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 diff --git a/lib/SQL/Abstract/Manual/Specification.pod b/lib/SQL/Abstract/Manual/Specification.pod index ed58414..23ea0b1 100644 --- a/lib/SQL/Abstract/Manual/Specification.pod +++ b/lib/SQL/Abstract/Manual/Specification.pod @@ -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 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