AlignDB-SQL
view release on metacpan or search on metacpan
t/04.copy.t view on Meta::CPAN
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 3;
BEGIN {
use_ok('AlignDB::SQL');
}
sub ns {
AlignDB::SQL->new;
}
my $stmt = ns();
ok $stmt, 'Created SQL object';
# Replace
$stmt = ns();
$stmt->add_select( foo => 'foo' );
$stmt->add_select( 'COUNT(*)' => 'count' );
$stmt->from( [qw(baz)] );
$stmt->add_where( foo => 1 );
$stmt->group( { column => 'baz' } );
$stmt->order( { column => 'foo', desc => 'DESC' } );
$stmt->limit(2);
$stmt->add_having( count => 2 );
$stmt->replace( { foo => 'foobar', baz => 'barbaz' } );
my $stmt_copy = $stmt->copy;
is $stmt->as_sql, $stmt_copy->as_sql, "Copy, clone, duplicate or what ever";
( run in 2.958 seconds using v1.01-cache-2.11-cpan-140bd7fdf52 )