1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More tests => 3;
7use Test::Exception;
8
9use SQL::Abstract::Limit;
10use SQL::Abstract;
11
12# 1, 2
13{
14    my $sql = SQL::Abstract::Limit->new( limit_dialect => 'LimitOffset' );
15    
16    #                       table       fields where  order   rows   offset
17    my $stmt = $sql->select("MY_TABLE", "*",   undef, ["id"], undef, undef);
18    
19    my $expect = 'SELECT * FROM MY_TABLE ORDER BY id';
20    
21    like( $stmt, qr~\Q$expect\E~, 'no-LIMIT with ORDER BY' );
22    
23    
24    
25    
26    #my $sql_ab = SQL::Abstract->new;
27    
28    my $stmt2 = SQL::Abstract->new->select("MY_TABLE", "*",   undef, ["id"]);
29    
30    like( $stmt2, qr~\Q$expect\E~, 'SQL::Abstract base stmt' );
31}
32
33# 3 bug in pre-0.1: order clause missing if no limit clause specified
34{
35    my $sql = SQL::Abstract::Limit->new( limit_dialect => 'LimitOffset' );
36    
37    my $stmt = $sql->where( { fee => 'fi' }, ["id"] );
38    
39    like( $stmt, qr/ORDER BY id/, 'got an order_by clause' );
40    
41    #warn $stmt;
42    
43}
44
45
46