NAME
SQL::Composer - sql builder
SYNOPSIS
DESCRIPTION
Raw SQL
my $expr = SQL::Composer::Expression->new( expr => \ 'a = b' );
my $sql = $expr ->to_sql;
my @bind = $expr ->to_bind;
|
Raw SQL with bind
my $expr = SQL::Composer::Expression->new( expr => \[ 'a = ?' , 'b' ]);
my $sql = $expr ->to_sql;
my @bind = $expr ->to_bind;
|
Simple SQL
my $expr = SQL::Composer::Expression->new( expr => [ a => 'b' ]);
my $sql = $expr ->to_sql;
is $sql , '`a` = ?' ;
my @bind = $expr ->to_bind;
is_deeply \ @bind , [ 'b' ];
|
Expression with custom operator
my $expr = SQL::Composer::Expression->new( expr => [ a => { '>' => 'b' }]);
my $sql = $expr ->to_sql;
is $sql , '`a` > ?' ;
my @bind = $expr ->to_bind;
is_deeply \ @bind , [ 'b' ];
|
Expression with column name
my $expr = SQL::Composer::Expression->new( expr => [ a => { '-col' => 'b' }]);
my $sql = $expr ->to_sql;
is $sql , '`a` = `b`' ;
my @bind = $expr ->to_bind;
is_deeply \ @bind , [];
|
Mixed logical expression
my $expr =
SQL::Composer::Expression->new(
expr => [ -or => [ a => 'b' , -and => [ c => 'd' , 'e' => 'f' ]]]);
my $sql = $expr ->to_sql;
my @bind = $expr ->to_bind;
|
IN
my $expr = SQL::Composer::Expression->new( expr => [ a => [ 'b' , 'c' , 'd' ]]);
my $sql = $expr ->to_sql;
my @bind = $expr ->to_bind;
|