[Bast-commits] r9773 - in SQL-Abstract/1.x/trunk: .
lib/SQL/Abstract t
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Thu Oct 21 14:51:31 GMT 2010
Author: ribasushi
Date: 2010-10-21 14:51:31 +0000 (Thu, 21 Oct 2010)
New Revision: 9773
Modified:
SQL-Abstract/1.x/trunk/Changes
SQL-Abstract/1.x/trunk/lib/SQL/Abstract/Tree.pm
SQL-Abstract/1.x/trunk/t/14roundtrippin.t
Log:
Fix default value inserts (an op can have an empty arglist)
Modified: SQL-Abstract/1.x/trunk/Changes
===================================================================
--- SQL-Abstract/1.x/trunk/Changes 2010-10-21 13:53:11 UTC (rev 9772)
+++ SQL-Abstract/1.x/trunk/Changes 2010-10-21 14:51:31 UTC (rev 9773)
@@ -10,6 +10,7 @@
- Special handle IS NOT? NULL
- Make sure unparse() does not destroy a passed in \@bindargs
- Support ops with _'s in them (valid in Oracle)
+ - Properly parse both types of default value inserts
revision 1.68 2010-09-16
----------------------------
Modified: SQL-Abstract/1.x/trunk/lib/SQL/Abstract/Tree.pm
===================================================================
--- SQL-Abstract/1.x/trunk/lib/SQL/Abstract/Tree.pm 2010-10-21 13:53:11 UTC (rev 9772)
+++ SQL-Abstract/1.x/trunk/lib/SQL/Abstract/Tree.pm 2010-10-21 14:51:31 UTC (rev 9773)
@@ -63,7 +63,7 @@
)',
'ON',
'WHERE',
- 'VALUES',
+ '(?: DEFAULT \s+ )? VALUES',
'EXISTS',
'GROUP \s+ BY',
'HAVING',
@@ -318,8 +318,8 @@
elsif ( $token =~ / ^ $expr_start_re $ /x ) {
my $op = uc $token;
my $right = $self->_recurse_parse($tokens, PARSE_IN_EXPR);
- $left = $left ? [ $left, [$op => [$right] ]]
- : [ $op => [$right] ];
+ $left = $left ? [ $left, [$op => [$right||()] ]]
+ : [ $op => [$right||()] ];
}
# NOT
elsif ( $token =~ /^ NOT $/ix ) {
Modified: SQL-Abstract/1.x/trunk/t/14roundtrippin.t
===================================================================
--- SQL-Abstract/1.x/trunk/t/14roundtrippin.t 2010-10-21 13:53:11 UTC (rev 9772)
+++ SQL-Abstract/1.x/trunk/t/14roundtrippin.t 2010-10-21 14:51:31 UTC (rev 9773)
@@ -7,14 +7,16 @@
my $sqlat = SQL::Abstract::Tree->new;
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 [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]"
+ "INSERT INTO artist DEFAULT VALUES",
+ "INSERT INTO artist VALUES ()",
+ "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 [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]",
);
for (@sql) {
- is_same_sql($_, $sqlat->format($_), 'roundtrip works');
+ is_same_sql($_, $sqlat->format($_), 'roundtrip works');
}
More information about the Bast-commits
mailing list