[Bast-commits] r9657 - SQL-Abstract/1.x/branches/sqla-tree/t
frew at dev.catalyst.perl.org
frew at dev.catalyst.perl.org
Thu Aug 26 04:21:44 GMT 2010
Author: frew
Date: 2010-08-26 05:21:44 +0100 (Thu, 26 Aug 2010)
New Revision: 9657
Modified:
SQL-Abstract/1.x/branches/sqla-tree/t/00new.t
SQL-Abstract/1.x/branches/sqla-tree/t/01generate.t
SQL-Abstract/1.x/branches/sqla-tree/t/02where.t
SQL-Abstract/1.x/branches/sqla-tree/t/03values.t
SQL-Abstract/1.x/branches/sqla-tree/t/04modifiers.t
SQL-Abstract/1.x/branches/sqla-tree/t/05in_between.t
SQL-Abstract/1.x/branches/sqla-tree/t/06order_by.t
SQL-Abstract/1.x/branches/sqla-tree/t/07subqueries.t
SQL-Abstract/1.x/branches/sqla-tree/t/08special_ops.t
SQL-Abstract/1.x/branches/sqla-tree/t/10test.t
Log:
revert changes to tests; functional interface MUST REMAIN
Modified: SQL-Abstract/1.x/branches/sqla-tree/t/00new.t
===================================================================
--- SQL-Abstract/1.x/branches/sqla-tree/t/00new.t 2010-08-25 04:43:44 UTC (rev 9656)
+++ SQL-Abstract/1.x/branches/sqla-tree/t/00new.t 2010-08-26 04:21:44 UTC (rev 9657)
@@ -4,10 +4,8 @@
use warnings;
use Test::More;
-use SQL::Abstract::Test;
+use SQL::Abstract::Test import => ['is_same_sql_bind'];
-my $sqlat = SQL::Abstract::Test->new;
-
#LDNOTE: renamed all "bind" into "where" because that's what they are
my @handle_tests = (
@@ -17,7 +15,7 @@
# stmt => 'SELECT * FROM test WHERE ( a = ? OR b = ? )'
# LDNOTE: modified the line above (changing the test suite!!!) because
# the test was not consistent with the doc: hashrefs should not be
-# influenced by the current logic, they always mean 'AND'. So
+# influenced by the current logic, they always mean 'AND'. So
# { a => 4, b => 0} should ALWAYS mean ( a = ? AND b = ? ).
#
# acked by RIBASUSHI
@@ -94,11 +92,11 @@
{
args => {convert => "upper"},
stmt => 'SELECT * FROM test WHERE ( ( UPPER(hostname) IN ( UPPER(?), UPPER(?), UPPER(?), UPPER(?) ) AND ( ( UPPER(ticket) = UPPER(?) ) OR ( UPPER(ticket) = UPPER(?) ) OR ( UPPER(ticket) = UPPER(?) ) ) ) OR ( UPPER(tack) BETWEEN UPPER(?) AND UPPER(?) ) OR ( ( ( UPPER(a) = UPPER(?) ) OR ( UPPER(a) = UPPER(?) ) OR ( UPPER(a) = UPPER(?) ) ) AND ( ( UPPER(e) != UPPER(?) ) OR ( UPPER(e) != UPPER(?) ) ) AND UPPER(q) NOT IN ( UPPER(?), UPPER(?), UPPER(?), UPPER(?), UPPER(?), UPPER(?), UPPER(?) ) ) )',
- where => [ { ticket => [11, 12, 13],
+ where => [ { ticket => [11, 12, 13],
hostname => { in => ['ntf', 'avd', 'bvd', '123'] } },
{ tack => { between => [qw/tick tock/] } },
- { a => [qw/b c d/],
- e => { '!=', [qw(f g)] },
+ { a => [qw/b c d/],
+ e => { '!=', [qw(f g)] },
q => { 'not in', [14..20] } } ],
},
);
@@ -118,7 +116,7 @@
# LDNOTE: this original test suite from NWIGER did no comparisons
# on @bind values, just checking if @bind is nonempty.
# So here we just fake a [1] bind value for the comparison.
- $sqlat->is_same_sql_bind($stmt, [@bind ? 1 : 0], $_->{stmt}, [1]);
+ is_same_sql_bind($stmt, [@bind ? 1 : 0], $_->{stmt}, [1]);
}
Modified: SQL-Abstract/1.x/branches/sqla-tree/t/01generate.t
===================================================================
--- SQL-Abstract/1.x/branches/sqla-tree/t/01generate.t 2010-08-25 04:43:44 UTC (rev 9656)
+++ SQL-Abstract/1.x/branches/sqla-tree/t/01generate.t 2010-08-26 04:21:44 UTC (rev 9657)
@@ -6,8 +6,7 @@
use Test::Warn;
use Test::Exception;
-use SQL::Abstract::Test;
-my $sqlat = SQL::Abstract::Test->new;
+use SQL::Abstract::Test import => ['is_same_sql_bind'];
use SQL::Abstract;
@@ -573,7 +572,7 @@
else {
$cref->();
}
- $sqlat->is_same_sql_bind(
+ is_same_sql_bind(
$stmt,
\@bind,
$quoted ? $t->{stmt_q}: $t->{stmt},
Modified: SQL-Abstract/1.x/branches/sqla-tree/t/02where.t
===================================================================
--- SQL-Abstract/1.x/branches/sqla-tree/t/02where.t 2010-08-25 04:43:44 UTC (rev 9656)
+++ SQL-Abstract/1.x/branches/sqla-tree/t/02where.t 2010-08-26 04:21:44 UTC (rev 9657)
@@ -4,10 +4,8 @@
use warnings;
use Test::More;
use Test::Exception;
-use SQL::Abstract::Test;
+use SQL::Abstract::Test import => ['is_same_sql_bind'];
-my $sqlat = SQL::Abstract::Test->new;
-
use Data::Dumper;
use SQL::Abstract;
@@ -108,7 +106,7 @@
},
{
- where => {
+ where => {
priority => [ {'>', 3}, {'<', 1} ],
requestor => \'is not null',
},
@@ -118,7 +116,7 @@
},
{
- where => {
+ where => {
requestor => { '!=', ['-and', undef, ''] },
},
stmt => " WHERE ( requestor IS NOT NULL AND requestor != ? )",
@@ -126,9 +124,9 @@
},
{
- where => {
+ where => {
priority => [ {'>', 3}, {'<', 1} ],
- requestor => { '!=', undef },
+ requestor => { '!=', undef },
},
order => [qw/a b c d e f g/],
stmt => " WHERE ( ( ( priority > ? ) OR ( priority < ? ) ) AND requestor IS NOT NULL )"
@@ -137,9 +135,9 @@
},
{
- where => {
+ where => {
priority => { 'between', [1, 3] },
- requestor => { 'like', undef },
+ requestor => { 'like', undef },
},
order => \'requestor, ticket',
#LDNOTE: modified parentheses
@@ -151,12 +149,12 @@
{
- where => {
+ where => {
id => 1,
- num => {
- '<=' => 20,
- '>' => 10,
- },
+ num => {
+ '<=' => 20,
+ '>' => 10,
+ },
},
# LDNOTE : modified test below, just parentheses differ
#
@@ -392,9 +390,9 @@
local $Data::Dumper::Terse = 1;
my $sql = SQL::Abstract->new;
my($stmt, @bind);
- lives_ok (sub {
+ lives_ok (sub {
($stmt, @bind) = $sql->where($case->{where}, $case->{order});
- $sqlat->is_same_sql_bind($stmt, \@bind, $case->{stmt}, $case->{bind})
+ is_same_sql_bind($stmt, \@bind, $case->{stmt}, $case->{bind})
|| diag "Search term:\n" . Dumper $case->{where};
});
}
Modified: SQL-Abstract/1.x/branches/sqla-tree/t/03values.t
===================================================================
--- SQL-Abstract/1.x/branches/sqla-tree/t/03values.t 2010-08-25 04:43:44 UTC (rev 9656)
+++ SQL-Abstract/1.x/branches/sqla-tree/t/03values.t 2010-08-26 04:21:44 UTC (rev 9657)
@@ -4,10 +4,8 @@
use warnings;
use Test::More;
-use SQL::Abstract::Test;
+use SQL::Abstract::Test import => [qw/is_same_sql_bind is_same_bind/];
-my $sqlat = SQL::Abstract::Test->new;
-
use SQL::Abstract;
my @data = (
@@ -96,7 +94,7 @@
{
my $sql = SQL::Abstract->new;
- my $data = {
+ my $data = {
event => 'rapture',
stuff => 'fluff',
time => \ 'now()',
@@ -108,14 +106,14 @@
my ($stmt, @bind) = $sql->insert ('table', $data);
- $sqlat->is_same_sql_bind (
+ is_same_sql_bind (
$stmt,
\@bind,
'INSERT INTO table ( event, stuff, time, xfunc, yfunc, zfunc, zzlast) VALUES ( ?, ?, now(), xfunc (?), yfunc(?), zfunc(?), ? )',
[qw/rapture fluff ystuff zstuff zzstuff/], # event < stuff
);
- $sqlat->is_same_bind (
+ is_same_bind (
[$sql->values ($data)],
[@bind],
'values() output matches that of initial bind'
Modified: SQL-Abstract/1.x/branches/sqla-tree/t/04modifiers.t
===================================================================
--- SQL-Abstract/1.x/branches/sqla-tree/t/04modifiers.t 2010-08-25 04:43:44 UTC (rev 9656)
+++ SQL-Abstract/1.x/branches/sqla-tree/t/04modifiers.t 2010-08-26 04:21:44 UTC (rev 9657)
@@ -4,10 +4,8 @@
use warnings;
use Test::More;
use Test::Exception;
-use SQL::Abstract::Test;
+use SQL::Abstract::Test import => ['is_same_sql_bind'];
-my $sqlat = SQL::Abstract::Test->new;
-
use Data::Dumper;
use Storable qw/dclone/;
use SQL::Abstract;
@@ -19,7 +17,7 @@
limitation of one modifier type per hahsref)
* When in condition context i.e. where => { -or { a = 1 } }, each modifier
affects only the immediate element following it.
- * When in column multi-condition context i.e.
+ * When in column multi-condition context i.e.
where => { x => { '!=', [-and, [qw/1 2 3/]] } }, a modifier affects the
OUTER ARRAYREF if and only if it is the first element of said ARRAYREF
@@ -70,7 +68,7 @@
%{$and_or_args->{or}},
},
- # test modifiers within hashrefs
+ # test modifiers within hashrefs
{
where => { -or => [
[ foo => 1, bar => 2 ],
@@ -86,7 +84,7 @@
%{$and_or_args->{or_and}},
},
- # test modifiers within arrayrefs
+ # test modifiers within arrayrefs
{
where => [ -or => [
[ foo => 1, bar => 2 ],
@@ -164,8 +162,8 @@
# the -and should affect the OUTER arrayref, while the internal structures remain intact
{
- where => { x => [
- -and => [ 1, 2 ], { -like => 'x%' }
+ where => { x => [
+ -and => [ 1, 2 ], { -like => 'x%' }
]},
stmt => 'WHERE (x = ? OR x = ?) AND x LIKE ?',
bind => [qw/1 2 x%/],
@@ -211,7 +209,7 @@
bind => [1 .. 13],
},
- # 1st -and is in column mode, thus flips the entire array, whereas the
+ # 1st -and is in column mode, thus flips the entire array, whereas the
# 2nd one is just a condition modifier
{
where => [
@@ -388,9 +386,9 @@
my $sql = SQL::Abstract->new ($case->{args} || {});
my $where_copy = dclone($case->{where});
- lives_ok (sub {
+ lives_ok (sub {
my ($stmt, @bind) = $sql->where($case->{where});
- $sqlat->is_same_sql_bind(
+ is_same_sql_bind(
$stmt,
\@bind,
$case->{stmt},
@@ -415,7 +413,7 @@
my $sql = SQL::Abstract->new ($case->{args} || {});
lives_ok (sub {
my ($stmt, @bind) = $sql->where($case->{where});
- $sqlat->is_same_sql_bind(
+ is_same_sql_bind(
$stmt,
\@bind,
$case->{stmt},
@@ -441,7 +439,7 @@
lives_ok (sub {
my ($old_s, @old_b) = $sql->where($case->{backcompat});
my ($new_s, @new_b) = $sql->where($case->{correct});
- $sqlat->is_same_sql_bind(
+ is_same_sql_bind(
$old_s, \@old_b,
$new_s, \@new_b,
'Backcompat and the correct(tm) syntax result in identical statements',
Modified: SQL-Abstract/1.x/branches/sqla-tree/t/05in_between.t
===================================================================
--- SQL-Abstract/1.x/branches/sqla-tree/t/05in_between.t 2010-08-25 04:43:44 UTC (rev 9656)
+++ SQL-Abstract/1.x/branches/sqla-tree/t/05in_between.t 2010-08-26 04:21:44 UTC (rev 9657)
@@ -4,10 +4,8 @@
use warnings;
use Test::More;
use Test::Exception;
-use SQL::Abstract::Test;
+use SQL::Abstract::Test import => ['is_same_sql_bind'];
-my $sqlat = SQL::Abstract::Test->new;
-
use Data::Dumper;
use SQL::Abstract;
@@ -158,9 +156,9 @@
my @w;
local $SIG{__WARN__} = sub { push @w, @_ };
my $sql = SQL::Abstract->new ($case->{args} || {});
- lives_ok (sub {
+ lives_ok (sub {
my ($stmt, @bind) = $sql->where($case->{where});
- $sqlat->is_same_sql_bind(
+ is_same_sql_bind(
$stmt,
\@bind,
$case->{stmt},
Modified: SQL-Abstract/1.x/branches/sqla-tree/t/06order_by.t
===================================================================
--- SQL-Abstract/1.x/branches/sqla-tree/t/06order_by.t 2010-08-25 04:43:44 UTC (rev 9656)
+++ SQL-Abstract/1.x/branches/sqla-tree/t/06order_by.t 2010-08-26 04:21:44 UTC (rev 9657)
@@ -7,11 +7,8 @@
use SQL::Abstract;
-use SQL::Abstract::Test;
-
-my $sqlat = SQL::Abstract::Test->new;
-
-my @cases =
+use SQL::Abstract::Test import => ['is_same_sql_bind'];
+my @cases =
(
{
given => \'colA DESC',
@@ -119,7 +116,7 @@
my ($stat, @bind);
($stat, @bind) = $sql->_order_by($case->{given});
- $sqlat->is_same_sql_bind (
+ is_same_sql_bind (
$stat,
\@bind,
$case->{expects},
@@ -127,7 +124,7 @@
);
($stat, @bind) = $sqlq->_order_by($case->{given});
- $sqlat->is_same_sql_bind (
+ is_same_sql_bind (
$stat,
\@bind,
$case->{expects_quoted},
Modified: SQL-Abstract/1.x/branches/sqla-tree/t/07subqueries.t
===================================================================
--- SQL-Abstract/1.x/branches/sqla-tree/t/07subqueries.t 2010-08-25 04:43:44 UTC (rev 9656)
+++ SQL-Abstract/1.x/branches/sqla-tree/t/07subqueries.t 2010-08-26 04:21:44 UTC (rev 9657)
@@ -4,10 +4,8 @@
use warnings;
use Test::More;
-use SQL::Abstract::Test;
+use SQL::Abstract::Test import => ['is_same_sql_bind'];
-my $sqlat = SQL::Abstract::Test->new;
-
use SQL::Abstract;
my $sql = SQL::Abstract->new;
@@ -29,7 +27,7 @@
#2
($sub_stmt, @sub_bind)
- = $sql->select("t1", "c1", {c2 => {"<" => 100},
+ = $sql->select("t1", "c1", {c2 => {"<" => 100},
c3 => {-like => "foo%"}});
$where = {
foo => 1234,
@@ -42,7 +40,7 @@
};
#3
-($sub_stmt, @sub_bind)
+($sub_stmt, @sub_bind)
= $sql->select("t1", "*", {c1 => 1, c2 => \"> t0.c0"});
$where = {
foo => 1234,
@@ -66,7 +64,7 @@
#5
-($sub_stmt, @sub_bind)
+($sub_stmt, @sub_bind)
= $sql->where({age => [{"<" => 10}, {">" => 20}]});
$sub_stmt =~ s/^ where //i; # don't want "WHERE" in the subclause
$where = {
@@ -98,7 +96,7 @@
for (@tests) {
my($stmt, @bind) = $sql->where($_->{where}, $_->{order});
- $sqlat->is_same_sql_bind($stmt, \@bind, $_->{stmt}, $_->{bind});
+ is_same_sql_bind($stmt, \@bind, $_->{stmt}, $_->{bind});
}
Modified: SQL-Abstract/1.x/branches/sqla-tree/t/08special_ops.t
===================================================================
--- SQL-Abstract/1.x/branches/sqla-tree/t/08special_ops.t 2010-08-25 04:43:44 UTC (rev 9656)
+++ SQL-Abstract/1.x/branches/sqla-tree/t/08special_ops.t 2010-08-26 04:21:44 UTC (rev 9657)
@@ -4,16 +4,14 @@
use warnings;
use Test::More;
-use SQL::Abstract::Test;
+use SQL::Abstract::Test import => ['is_same_sql_bind'];
-my $sqlat = SQL::Abstract::Test->new;
-
use SQL::Abstract;
my $sqlmaker = SQL::Abstract->new(special_ops => [
# special op for MySql MATCH (field) AGAINST(word1, word2, ...)
- {regex => qr/^match$/i,
+ {regex => qr/^match$/i,
handler => sub {
my ($self, $field, $op, $arg) = @_;
$arg = [$arg] if not ref $arg;
@@ -28,7 +26,7 @@
},
# special op for Basis+ NATIVE
- {regex => qr/^native$/i,
+ {regex => qr/^native$/i,
handler => sub {
my ($self, $field, $op, $arg) = @_;
$arg =~ s/'/''/g;
@@ -41,7 +39,7 @@
my @tests = (
- #1
+ #1
{ where => {foo => {-match => 'foo'},
bar => {-match => [qw/foo bar/]}},
stmt => " WHERE ( MATCH (bar) AGAINST (?, ?) AND MATCH (foo) AGAINST (?) )",
@@ -62,7 +60,7 @@
for (@tests) {
my($stmt, @bind) = $sqlmaker->where($_->{where}, $_->{order});
- $sqlat->is_same_sql_bind($stmt, \@bind, $_->{stmt}, $_->{bind});
+ is_same_sql_bind($stmt, \@bind, $_->{stmt}, $_->{bind});
}
Modified: SQL-Abstract/1.x/branches/sqla-tree/t/10test.t
===================================================================
--- SQL-Abstract/1.x/branches/sqla-tree/t/10test.t 2010-08-25 04:43:44 UTC (rev 9656)
+++ SQL-Abstract/1.x/branches/sqla-tree/t/10test.t 2010-08-26 04:21:44 UTC (rev 9657)
@@ -23,7 +23,7 @@
my @sql_tests = (
- # WHERE condition - equal
+ # WHERE condition - equal
{
equal => 1,
statements => [
@@ -831,10 +831,10 @@
) +
3;
-use_ok('SQL::Abstract::Test');
+use_ok('SQL::Abstract::Test', import => [qw(
+ eq_sql_bind eq_sql eq_bind is_same_sql_bind
+)]);
-my $sqlat = SQL::Abstract::Test->new;
-
for my $test (@sql_tests) {
my $statements = $test->{statements};
while (@$statements) {
@@ -843,7 +843,7 @@
no warnings qw/once/; # perl 5.10 is dumb
$sqlat->parenthesis_significant($test->{parenthesis_significant});
- my $equal = $sqlat->eq_sql($sql1, $sql2);
+ my $equal = eq_sql($sql1, $sql2);
TODO: {
local $TODO = $test->{todo} if $test->{todo};
@@ -857,8 +857,8 @@
if ($equal ^ $test->{equal}) {
diag("sql1: $sql1");
diag("sql2: $sql2");
- note('ast1: ' . Dumper $sqlat->parse($sql1));
- note('ast2: ' . Dumper $sqlat->parse($sql2));
+ note('ast1: ' . Dumper SQL::Abstract::Test::parse ($sql1));
+ note('ast2: ' . Dumper SQL::Abstract::Test::parse ($sql2));
}
}
}
@@ -870,7 +870,7 @@
while (@$bindvals) {
my $bind1 = shift @$bindvals;
foreach my $bind2 (@$bindvals) {
- my $equal = $sqlat->eq_bind($bind1, $bind2);
+ my $equal = eq_bind($bind1, $bind2);
if ($test->{equal}) {
ok($equal, "equal bind values considered equal");
} else {
@@ -885,7 +885,7 @@
}
}
-ok($sqlat->eq_sql_bind(
+ok(eq_sql_bind(
"SELECT * FROM foo WHERE id = ?", [42],
"SELECT * FROM foo WHERE (id = ?)", [42],
),
@@ -893,14 +893,14 @@
);
-ok(!$sqlat->eq_sql_bind(
+ok(!eq_sql_bind(
"SELECT * FROM foo WHERE id = ?", [42],
"SELECT * FROM foo WHERE (id = ?)", [0],
),
"eq_sql_bind considers equal SQL expressions and different bind values different"
);
-ok(!$sqlat->eq_sql_bind(
+ok(!eq_sql_bind(
"SELECT * FROM foo WHERE id = ?", [42],
"SELECT * FROM bar WHERE (id = ?)", [42],
),
More information about the Bast-commits
mailing list