"SELECT inner_forum_roles.forum_id FROM forum_roles AS inner_forum_roles LEFT JOIN user_roles AS inner_user_roles USING(user_role_type_id) WHERE inner_user_roles.user_id = users__row.user_id",
"SELECT * FROM foo WHERE foo.a @@ to_tsquery('word')",
"SELECT * FROM foo ORDER BY name + ?, [me].[id]",
+ "SELECT foo AS bar FROM baz ORDER BY x + ? DESC, baz.g",
+ # deliberate batshit insanity
+ "SELECT foo FROM bar WHERE > 12",
);
# FIXME FIXME FIXME
$sqlat->unparse($ast);
};
- # deal with parenthesis readjustment
- $_ =~ s/\s*([\(\)])\s*/$1 /g
+ # deal with whitespace around parenthesis readjustment
+ $_ =~ s/ \s* ( [ \(\) ] ) \s* /$1/gx
for ($orig, $reassembled);
is (
};
}
+# this is invalid SQL, we are just checking that the parser
+# does not inadvertently make it right
+my $sql = 'SELECT * FROM foo WHERE x IN ( ( 1 ) )';
+is(
+ $sqlat->unparse($sqlat->parse($sql)),
+ $sql,
+ 'Multi-parens around IN survive',
+);
+
lives_ok { $sqlat->unparse( $sqlat->parse( <<'EOS' ) ) } 'Able to parse/unparse grossly malformed sql';
SELECT
(