From: Peter Rabbitson Date: Sun, 22 Mar 2009 22:24:07 +0000 (+0000) Subject: Reverting massive test breakage by LDAMI - this stuff can not happen in 1.x, has... X-Git-Tag: v1.70~201 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e30faf881505a049a20b9d9a3ca5d3cc1d0e09a0;p=dbsrgits%2FSQL-Abstract.git Reverting massive test breakage by LDAMI - this stuff can not happen in 1.x, has to wait for 2.x (some tests changes are reasonable, acking where appropriate) --- diff --git a/t/00new.t b/t/00new.t index eac01ee..b6927da 100755 --- a/t/00new.t +++ b/t/00new.t @@ -17,6 +17,8 @@ my @handle_tests = ( # the test was not consistent with the doc: hashrefs should not be # influenced by the current logic, they always mean 'AND'. So # { a => 4, b => 0} should ALWAYS mean ( a = ? AND b = ? ). +# +# acked by RIBASUSHI stmt => 'SELECT * FROM test WHERE ( a = ? AND b = ? )' }, #2 @@ -39,6 +41,7 @@ my @handle_tests = ( args => {cmp => "=", logic => 'or'}, # LDNOTE idem # stmt => 'SELECT * FROM test WHERE ( a = ? OR b = ? )' +# acked by RIBASUSHI stmt => 'SELECT * FROM test WHERE ( a = ? AND b = ? )' }, #6 @@ -51,6 +54,7 @@ my @handle_tests = ( args => {logic => "or", cmp => "like"}, # LDNOTE idem # stmt => 'SELECT * FROM test WHERE ( a LIKE ? OR b LIKE ? )' +# acked by RIBASUSHI stmt => 'SELECT * FROM test WHERE ( a LIKE ? AND b LIKE ? )' }, #8 @@ -87,15 +91,7 @@ my @handle_tests = ( #14 { args => {convert => "upper"}, -# LDNOTE : modified the test below, because modified the semantics -# of "e => { '!=', [qw(f g)] }" : generating "e != 'f' OR e != 'g'" -# is nonsense (will always be true whatever the value of e). Since -# this is a 'negative' operator, we must apply the Morgan laws and -# interpret it as "e != 'f' AND e != 'g'" (and actually the user -# should rather write "e => {-not_in => [qw/f g/]}". - -# 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(?) ) ) )', - 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(?) ) AND ( UPPER(e) != UPPER(?) ) ) AND UPPER(q) NOT IN ( UPPER(?), UPPER(?), UPPER(?), UPPER(?), UPPER(?), UPPER(?), 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], hostname => { in => ['ntf', 'avd', 'bvd', '123'] } }, { tack => { between => [qw/tick tock/] } }, diff --git a/t/01generate.t b/t/01generate.t index ee8fd83..bee3d9d 100755 --- a/t/01generate.t +++ b/t/01generate.t @@ -253,13 +253,10 @@ my @tests = ( tasty => { '!=', [qw(yes YES)] }, -nest => [ face => [ -or => {'=', 'mr.happy'}, {'=', undef} ] ] }, ], -# LDNOTE : modified the test below, same reasons as #14 in 00where.t stmt => 'UPDATE taco_punches SET one = ?, three = ? WHERE ( ( ( ( ( face = ? ) OR ( face IS NULL ) ) ) )' -# . ' AND ( ( bland != ? ) AND ( bland != ? ) ) AND ( ( tasty != ? ) OR ( tasty != ? ) ) )', - . ' AND ( ( bland != ? ) AND ( bland != ? ) ) AND ( ( tasty != ? ) AND ( tasty != ? ) ) )', + . ' AND ( ( bland != ? ) AND ( bland != ? ) ) AND ( ( tasty != ? ) OR ( tasty != ? ) ) )', stmt_q => 'UPDATE `taco_punches` SET `one` = ?, `three` = ? WHERE ( ( ( ( ( `face` = ? ) OR ( `face` IS NULL ) ) ) )' -# . ' AND ( ( `bland` != ? ) AND ( `bland` != ? ) ) AND ( ( `tasty` != ? ) OR ( `tasty` != ? ) ) )', - . ' AND ( ( `bland` != ? ) AND ( `bland` != ? ) ) AND ( ( `tasty` != ? ) AND ( `tasty` != ? ) ) )', + . ' AND ( ( `bland` != ? ) AND ( `bland` != ? ) ) AND ( ( `tasty` != ? ) OR ( `tasty` != ? ) ) )', bind => [qw(2 4 mr.happy yes YES yes YES)], }, #29 @@ -268,26 +265,18 @@ my @tests = ( args => ['jeff', '*', { name => {'like', '%smith%', -not_in => ['Nate','Jim','Bob','Sally']}, -nest => [ -or => [ -and => [age => { -between => [20,30] }, age => {'!=', 25} ], yob => {'<', 1976} ] ] } ], -# LDNOTE : original test below was WRONG with respect to the doc. -# [-and, [cond1, cond2], cond3] should mean (cond1 OR cond2) AND cond3 -# instead of (cond1 AND cond2) OR cond3. -# Probably a misconception because of '=>' notation -# in [-and => [cond1, cond2], cond3]. -# Also some differences in parentheses, but without impact on semantics. -# stmt => 'SELECT * FROM jeff WHERE ( ( ( ( ( ( ( age BETWEEN ? AND ? ) AND ( age != ? ) ) ) OR ( yob < ? ) ) ) )' -# . ' AND name NOT IN ( ?, ?, ?, ? ) AND name LIKE ? )', -# stmt_q => 'SELECT * FROM `jeff` WHERE ( ( ( ( ( ( ( `age` BETWEEN ? AND ? ) AND ( `age` != ? ) ) ) OR ( `yob` < ? ) ) ) )' -# . ' AND `name` NOT IN ( ?, ?, ?, ? ) AND `name` LIKE ? )', - stmt => 'SELECT * FROM jeff WHERE ( ( ( ( ( age BETWEEN ? AND ? ) OR ( age != ? ) ) AND ( yob < ? ) ) )' - . ' AND ( name NOT IN ( ?, ?, ?, ? ) AND name LIKE ? ) )', - stmt_q => 'SELECT * FROM `jeff` WHERE ( ( ( ( ( `age` BETWEEN ? AND ? ) OR ( `age` != ? ) ) AND ( `yob` < ? ) ) )' - . ' AND ( `name` NOT IN ( ?, ?, ?, ? ) AND `name` LIKE ? ) )', + stmt => 'SELECT * FROM jeff WHERE ( ( ( ( ( ( ( age BETWEEN ? AND ? ) AND ( age != ? ) ) ) OR ( yob < ? ) ) ) )' + . ' AND name NOT IN ( ?, ?, ?, ? ) AND name LIKE ? )', + stmt_q => 'SELECT * FROM `jeff` WHERE ( ( ( ( ( ( ( `age` BETWEEN ? AND ? ) AND ( `age` != ? ) ) ) OR ( `yob` < ? ) ) ) )' + . ' AND `name` NOT IN ( ?, ?, ?, ? ) AND `name` LIKE ? )', bind => [qw(20 30 25 1976 Nate Jim Bob Sally %smith%)] }, #30 { func => 'update', # LDNOTE : removed the "-maybe", because we no longer admit unknown ops +# +# acked by RIBASUSHI # args => ['fhole', {fpoles => 4}, [-maybe => {race => [-and => [qw(black white asian)]]}, args => ['fhole', {fpoles => 4}, [ {race => [-and => [qw(black white asian)]]}, {-nest => {firsttime => [-or => {'=','yes'}, undef]}}, @@ -311,6 +300,8 @@ my @tests = ( func => 'select', # LDNOTE: modified test below because we agreed with MST that literal SQL # should not automatically insert a '='; the user has to do it +# +# acked by MSTROUT # args => ['test', '*', { a => \["to_date(?, 'MM/DD/YY')", '02/02/02']}], args => ['test', '*', { a => \["= to_date(?, 'MM/DD/YY')", '02/02/02']}], stmt => q{SELECT * FROM test WHERE ( a = to_date(?, 'MM/DD/YY') )}, @@ -530,9 +521,9 @@ my @tests = ( { func => 'select', new => {bindtype => 'columns'}, - args => ['test', '*', { -or => [ -and => [ a => 'a', b => 'b' ],-and => [ c => 'c', d => 'd' ] ] }], - stmt => 'SELECT * FROM test WHERE ( ( ( ( ( a = ? ) AND ( b = ? ) ) ) OR ( ( ( c = ? ) AND ( d = ? ) ) ) ) )', - stmt_q => 'SELECT * FROM `test` WHERE ( ( ( ( ( `a` = ? ) AND ( `b` = ? ) ) ) OR ( ( ( `c` = ? ) AND ( `d` = ? ) ) ) ) )', + args => ['test', '*', { -or => [ -and => [ a => 'a', b => 'b' ], -and => [ c => 'c', d => 'd' ] ] }], + stmt => 'SELECT * FROM test WHERE ( a = ? AND b = ? ) OR ( c = ? AND d = ? )', + stmt_q => 'SELECT * FROM `test` WHERE ( `a` = ? AND `b` = ? ) OR ( `c` = ? AND `d` = ? )', bind => [[a => 'a'], [b => 'b'], [ c => 'c'],[ d => 'd']], }, diff --git a/t/02where.t b/t/02where.t index 39d620e..0c28faf 100755 --- a/t/02where.t +++ b/t/02where.t @@ -83,8 +83,9 @@ my @handle_tests = ( }, order => \'ticket, requestor', #LDNOTE: modified parentheses -# stmt => " WHERE ( completion_date BETWEEN ? AND ? AND status = ? ) ORDER BY ticket, requestor", - stmt => " WHERE ( ( completion_date BETWEEN ? AND ? ) AND status = ? ) ORDER BY ticket, requestor", +# +# acked by RIBASUSHI + stmt => "WHERE ( ( completion_date BETWEEN ? AND ? ) AND status = ? ) ORDER BY ticket, requestor", bind => [qw/2002-10-01 2003-02-06 completed/], }, @@ -132,7 +133,8 @@ my @handle_tests = ( }, order => \'requestor, ticket', #LDNOTE: modified parentheses -# stmt => " WHERE ( priority BETWEEN ? AND ? AND requestor IS NULL ) ORDER BY requestor, ticket", +# +# acked by RIBASUSHI stmt => " WHERE ( ( priority BETWEEN ? AND ? ) AND requestor IS NULL ) ORDER BY requestor, ticket", bind => [qw/1 3/], }, @@ -147,7 +149,8 @@ my @handle_tests = ( }, }, # LDNOTE : modified test below, just parentheses differ -# stmt => " WHERE ( id = ? AND num <= ? AND num > ? )", +# +# acked by RIBASUSHI stmt => " WHERE ( id = ? AND ( num <= ? AND num > ? ) )", bind => [qw/1 20 10/], }, @@ -160,10 +163,7 @@ my @handle_tests = ( wix => {'in' => [qw/zz yy/]}, wux => {'not_in' => [qw/30 40/]} }, -# LDNOTE: modified parentheses for BETWEEN (trivial). -# Also modified the logic of "not_like" (severe, same reasons as #14 in 00where.t) -# stmt => " WHERE ( ( ( foo NOT LIKE ? ) OR ( foo NOT LIKE ? ) OR ( foo NOT LIKE ? ) ) AND ( ( fum LIKE ? ) OR ( fum LIKE ? ) ) AND nix BETWEEN ? AND ? AND nox NOT BETWEEN ? AND ? AND wix IN ( ?, ? ) AND wux NOT IN ( ?, ? ) )", - stmt => " WHERE ( ( foo NOT LIKE ? AND foo NOT LIKE ? AND foo NOT LIKE ? ) AND ( ( fum LIKE ? ) OR ( fum LIKE ? ) ) AND ( nix BETWEEN ? AND ? ) AND ( nox NOT BETWEEN ? AND ? ) AND wix IN ( ?, ? ) AND wux NOT IN ( ?, ? ) )", + stmt => " WHERE ( ( ( foo NOT LIKE ? ) OR ( foo NOT LIKE ? ) OR ( foo NOT LIKE ? ) ) AND ( ( fum LIKE ? ) OR ( fum LIKE ? ) ) AND nix BETWEEN ? AND ? AND nox NOT BETWEEN ? AND ? AND wix IN ( ?, ? ) AND wux NOT IN ( ?, ? ) )", bind => [7,8,9,'a','b',100,200,150,160,'zz','yy','30','40'], },