X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fexpr-helpers.t;h=a64c9f37c3ef8f3394efe70d73219b5b0feb93e4;hb=1e55ce818fdf86cae62452653ae424da8a57d643;hp=79ee6001e9e50992a6a7efef7af92102816225d8;hpb=70a14d95f224db56555bce9a2d0ecf1950f5f7dc;p=dbsrgits%2FData-Query.git diff --git a/t/expr-helpers.t b/t/expr-helpers.t index 79ee600..a64c9f3 100644 --- a/t/expr-helpers.t +++ b/t/expr-helpers.t @@ -28,7 +28,7 @@ dq_sql_is Join( Select([ Identifier('*') ], Identifier('foo')), Identifier('bar'), - perl_operator('==', Identifier('foo', 'x'), Identifier('bar', 'y')) + perl_operator('==', Identifier('foo', 'x'), Identifier('bar', 'y')), ), ['SELECT * FROM foo JOIN bar ON foo.x = bar.y'], 'join on with dots (Join Select)'; @@ -39,7 +39,7 @@ dq_sql_is Join( Identifier('foo'), Identifier('bar'), - perl_operator('==', Identifier('foo', 'x'), Identifier('bar', 'y')) + perl_operator('==', Identifier('foo', 'x'), Identifier('bar', 'y')), ), ), ['SELECT * FROM foo JOIN bar ON foo.x = bar.y'], @@ -58,3 +58,42 @@ dq_sql_is ['SELECT * FROM foo WHERE x = ?', binding(1)], 'simple select with where and bind'; +dq_sql_is + Group ( + [ Identifier('x') ], + Select([ Identifier('*') ], Identifier('foo')), + ), + ['SELECT * FROM foo GROUP BY x'], + 'simple group by'; + +dq_sql_is + Select( + [ Identifier('*') ], + Join( + Identifier('foo'), + Identifier('bar'), + perl_operator('==', Identifier('foo', 'x'), Identifier('bar', 'y')), + 'left outer', + ), + ), + ['SELECT * FROM foo LEFT OUTER JOIN bar ON foo.x = bar.y'], + 'left outer join'; + +dq_sql_is + Select( + [ Operator({ 'SQL.Naive' => 'apply' }, [ Identifier('COUNT'), Identifier('*') ]) ], + Identifier('foo'), + ), + ['SELECT COUNT( * ) FROM foo'], + 'count'; + +dq_sql_is + Where( + Operator({ 'SQL.Naive' => 'BETWEEN' }, [ + Identifier('x'), + map Literal('SQL', '?', [ binding($_) ]), (1,2), + ]), + Select([ Identifier('*') ], Identifier('foo')), + ), + [ 'SELECT * FROM foo WHERE ( x BETWEEN ? AND ? )', map binding($_), 1, 2, ], + 'between';