File: 04.args.t

package info (click to toggle)
libsql-abstract-limit-perl 2%3A0.14.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 152 kB
  • sloc: perl: 531; makefile: 2
file content (45 lines) | stat: -rw-r--r-- 1,071 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/perl

use strict;
use warnings;

use Test::More tests => 3;
use Test::Exception;

use SQL::Abstract::Limit;
use SQL::Abstract;

# 1, 2
{
    my $sql = SQL::Abstract::Limit->new( limit_dialect => 'LimitOffset' );
    
    #                       table       fields where  order   rows   offset
    my $stmt = $sql->select("MY_TABLE", "*",   undef, ["id"], undef, undef);
    
    my $expect = 'SELECT * FROM MY_TABLE ORDER BY id';
    
    like( $stmt, qr~\Q$expect\E~, 'no-LIMIT with ORDER BY' );
    
    
    
    
    #my $sql_ab = SQL::Abstract->new;
    
    my $stmt2 = SQL::Abstract->new->select("MY_TABLE", "*",   undef, ["id"]);
    
    like( $stmt2, qr~\Q$expect\E~, 'SQL::Abstract base stmt' );
}

# 3 bug in pre-0.1: order clause missing if no limit clause specified
{
    my $sql = SQL::Abstract::Limit->new( limit_dialect => 'LimitOffset' );
    
    my $stmt = $sql->where( { fee => 'fi' }, ["id"] );
    
    like( $stmt, qr/ORDER BY id/, 'got an order_by clause' );
    
    #warn $stmt;
    
}