From: Matt S Trout Date: Tue, 16 Apr 2019 02:14:23 +0000 (+0000) Subject: fix up with clause code - got the parens wrong X-Git-Tag: v1.90_01~202 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=541af9148987e73b124229ee4f6b80d7c8d30e63;p=dbsrgits%2FSQL-Abstract.git fix up with clause code - got the parens wrong --- diff --git a/lib/SQL/Abstract/ExtraClauses.pm b/lib/SQL/Abstract/ExtraClauses.pm index 90716df..f471794 100644 --- a/lib/SQL/Abstract/ExtraClauses.pm +++ b/lib/SQL/Abstract/ExtraClauses.pm @@ -155,10 +155,9 @@ sub register_defaults { ) ] } @{$with->{queries}} ) ]; - return $self->join_clauses('', - [ $self->format_keyword(join '_', 'with', ($with->{type}||'')).' (' ], + return $self->join_clauses(' ', + [ $self->format_keyword(join '_', 'with', ($with->{type}||'')) ], $q_part, - [ ')' ], ); }); diff --git a/xt/clauses.t b/xt/clauses.t index 758a2ea..399fc66 100644 --- a/xt/clauses.t +++ b/xt/clauses.t @@ -194,7 +194,7 @@ $sql = $sqlac->select({ is_same_sql( $sql, - q{WITH (foo AS (SELECT 1)) SELECT * FROM foo}, + q{WITH foo AS (SELECT 1) SELECT * FROM foo}, ); $sql = $sqlac->update({ @@ -244,7 +244,7 @@ is_same_sql( $sql, q{ UPDATE tree_table JOIN ( - WITH RECURSIVE (tree_with_path(id, parent_id, path) AS ( + WITH RECURSIVE tree_with_path(id, parent_id, path) AS ( ( SELECT id, parent_id, CAST(id AS char(255)) AS path FROM tree_table @@ -256,7 +256,7 @@ is_same_sql( FROM tree_table AS t JOIN tree_with_path AS r ON t.parent_id = r.id ) - )) + ) SELECT * FROM tree_with_path ) AS tree ON tree.id = tree_with_path.id