/,
]
},
+ {
+ equal => 1,
+ todo => '( (x AND y) AND z ) should be reducable to ( x AND y AND z )',
+ statements => [
+ q/SELECT foo FROM bar WHERE a = 1 AND b = 1 AND c = 1/,
+ q/SELECT foo FROM bar WHERE (a = 1 AND b = 1) AND c = 1/,
+ q/SELECT foo FROM bar WHERE a = 1 AND (b = 1 AND c = 1)/,
+ ]
+ },
+ {
+ equal => 1,
+ todo => '( (x OR y) OR z ) should be reducable to ( x OR y OR z )',
+ statements => [
+ q/SELECT foo FROM bar WHERE a = 1 OR b = 1 OR c = 1/,
+ q/SELECT foo FROM bar WHERE (a = 1 OR b = 1) OR c = 1/,
+ q/SELECT foo FROM bar WHERE a = 1 OR (b = 1 OR c = 1)/,
+ ]
+ },
# WHERE condition - different
{
q/SELECT foo FROM bar JOIN quux ON a = 1 WHERE a = 1 AND b = 1/,
]
},
+ {
+ equal => 0,
+ statements => [
+ q/SELECT foo FROM bar WHERE a = 1 AND b = 1 OR c = 1/,
+ q/SELECT foo FROM bar WHERE (a = 1 AND b = 1) OR c = 1/,
+ q/SELECT foo FROM bar WHERE a = 1 AND (b = 1 OR c = 1)/,
+ ]
+ },
+ {
+ equal => 0,
+ statements => [
+ q/SELECT foo FROM bar WHERE a = 1 OR b = 1 AND c = 1/,
+ q/SELECT foo FROM bar WHERE (a = 1 OR b = 1) AND c = 1/,
+ q/SELECT foo FROM bar WHERE a = 1 OR (b = 1 AND c = 1)/,
+ ]
+ },
# JOIN condition - equal
{
my $sql1 = shift @$statements;
foreach my $sql2 (@$statements) {
my $equal = eq_sql($sql1, $sql2);
- if ($test->{equal}) {
- ok($equal, "equal SQL expressions considered equal");
- } else {
- ok(!$equal, "different SQL expressions considered not equal");
- }
-
- if ($equal ^ $test->{equal}) {
- diag("sql1: $sql1");
- diag("sql2: $sql2");
+ TODO: {
+ local $TODO = $test->{todo} if $test->{todo};
+
+ if ($test->{equal}) {
+ ok($equal, "equal SQL expressions should have been considered equal");
+ } else {
+ ok(!$equal, "different SQL expressions should have been considered not equal");
+ }
+
+ if ($equal ^ $test->{equal}) {
+ diag("sql1: $sql1");
+ diag("sql2: $sql2");
+ }
}
}
}