The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/usr/bin/perl -w

use strict;
use warnings;

use Test::More tests => 4;
use DBIx::Lite;

my $dbix = DBIx::Lite->connect('dbi:SQLite:dbname=t/test.db', '', '');

$dbix->dbh->do('DROP TABLE IF EXISTS books');
$dbix->dbh->do('CREATE TABLE books (id NUMBER, title TEXT, year NUMBER)');

$dbix->table('books')->insert({ id => 1, title => 'Camel Tales', year => 2012 });
$dbix->table('books')->insert({ id => 2, title => 'Camel Adventures', year => 2010 });

{
    my $count = $dbix->table('books')->count;
    is $count, 2, 'row count';
}

{
    my $book = $dbix->table('books')->find({ year => 2010 });
    isa_ok $book, 'DBIx::Lite::Row';
    is $book->id, 2, 'fetch result';
}

{
    my @titles = $dbix->table('books')->order_by('+title')->get_column('title');
    is_deeply \@titles, ['Camel Adventures', 'Camel Tales'], 'get_column';
}

__END__