From: Arthur Axel "fREW" Schmidt Date: Sat, 23 Oct 2010 02:18:52 +0000 (+0000) Subject: fix pagination keywords X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c0eaa9fd4c4b58970a8586adf1f598291b4cd9a7;p=scpubgit%2FQ-Branch.git fix pagination keywords --- diff --git a/Changes b/Changes index b093f21..3154611 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,9 @@ Revision history for SQL::Abstract revision 1.69 2010-10-22 ---------------------------- + - Add quotes for populated placeholders and make the background + magenta instead of cyan + - Color and indent pagination keywords - Fix a silly bug which broke placeholder fill-in in DBIC - Installs format-sql to format SQL passed in over STDIN - Switch the tokenizer to precompiled regexes (massive speedup) diff --git a/examples/console.pl b/examples/console.pl index 234c935..48fd5ec 100644 --- a/examples/console.pl +++ b/examples/console.pl @@ -8,6 +8,10 @@ my @sql = ( "SELECT a, b, c FROM foo WHERE foo.a =1 and foo.b LIKE 'station'", "SELECT * FROM (SELECT * FROM foobar) WHERE foo.a =1 and foo.b LIKE 'station'", "SELECT * FROM lolz WHERE ( foo.a =1 ) and foo.b LIKE 'station'", + "SELECT * LIMIT 5 OFFSET 5 FROM lolz ", + "SELECT * LIMIT 5 5 FROM lolz ", + "SELECT SKIP 5 FIRST 5 * FROM lolz ", + "SELECT FIRST 5 SKIP 5 * FROM lolz ", "UPDATE session SET expires = ? WHERE (id = ?)", "INSERT INTO Request (creation_date, is_private, owner_id, request) VALUES (? , ? , ? , ?)", "SELECT [screen].[id], [screen].[name], [screen].[section_id], [screen].[xtype] FROM [users_roles] [me] JOIN [roles] [role] ON [role].[id] = [me].[role_id] JOIN [roles_permissions] [role_permissions] ON [role_permissions].[role_id] = [role].[id] JOIN [permissions] [permission] ON [permission].[id] = [role_permissions].[permission_id] JOIN [permissionscreens] [permission_screens] ON [permission_screens].[permission_id] = [permission].[id] JOIN [screens] [screen] ON [screen].[id] = [permission_screens].[screen_id] WHERE ( [me].[user_id] = ? ) GROUP BY [screen].[id], [screen].[name], [screen].[section_id], [screen].[xtype]", diff --git a/lib/SQL/Abstract/Tree.pm b/lib/SQL/Abstract/Tree.pm index ee8509c..43c5fb7 100644 --- a/lib/SQL/Abstract/Tree.pm +++ b/lib/SQL/Abstract/Tree.pm @@ -68,6 +68,8 @@ my @expression_start_keywords = ( 'GROUP \s+ BY', 'HAVING', 'ORDER \s+ BY', + 'SKIP', + 'FIRST', 'LIMIT', 'OFFSET', 'FOR', @@ -151,6 +153,10 @@ my %indents = ( set => 1, into => 1, values => 1, + limit => 1, + offset => 1, + skip => 1, + first => 1, ); my %profiles = ( @@ -186,6 +192,11 @@ my %profiles = ( 'group by' => [$c->('yellow'), $c->('reset')], 'order by' => [$c->('yellow'), $c->('reset')], + + skip => [$c->('green'), $c->('reset')], + first => [$c->('green'), $c->('reset')], + limit => [$c->('green'), $c->('reset')], + offset => [$c->('green'), $c->('reset')], } ); } : (), @@ -210,15 +221,24 @@ my %profiles = ( 'insert into' => ['' , ''], update => ['' , ''], 'delete from' => ['' , ''], - where => ['' , ''], + + set => ['', ''], from => ['' , ''], + + where => ['' , ''], + values => ['', ''], + join => ['' , ''], + 'left join' => ['',''], on => ['' , ''], + 'group by' => ['', ''], 'order by' => ['', ''], - set => ['', ''], - into => ['', ''], - values => ['', ''], + + skip => ['', ''], + first => ['', ''], + limit => ['', ''], + offset => ['', ''], }, indentmap => { %indents }, },