The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

SQL::Entity::Condition - Entity SQL Condition abstraction.

DESCRIPTION

Represents sql condition.

SYNOPSIS

    use SQL::Entity::Condition ':all';

    #Creates "a = 1" condition
    my $cond = sql_cond('a', '=', 1);

    #Creates "a = 1 AND b > 1 AND c < 1" condition
    my $cond = sql_and( 
        sql_cond('a', '=', 1),
        sql_cond('b', '>', 1),
        sql_cond('c', '<', 1),
    );    

    Creates "a = 1 OR b > 1 OR c < 1" condition
    my $cond = sql_or( 
      sql_cond('a', '=', 1),
      sql_cond('b', '>', 1),
      sql_cond('c', '<', 1),
    );    

    Creates "(a = 1 AND  b = 1) OR c LIKE 1" condition
    my $cond = sql_and(
      sql_cond('a', '=', 1),
      sql_cond('b', '=', 1),
    )->or( 
      sql_cond('c', 'LIKE', 1)
    );

EXPORT

None by default. sql_cond sql_and sql_or by tag 'all'

ATTRIBUTES

operand1

First operand for condition.

set_operand1

Sets the first condition operand .

operator

Operator

operand2

Second operand for condition.

set_operand2

Sets the secound condition operand .

relation

Relation between compsite condition.

conditions

Association to composie condition

METHOD

new
condition_iterator
sql_cond( string | SQL::Entity::Column: $operand1, string: $operator, string | SQL::Entity::Column: $operand2) returns SQL::Entity::Condition

Create simple Condition object.

and

Create a composite Condition object with AND relation between current object and passed in condition list.

or

Create a composite Condition object with OR relation between current object an passed in condition list.

sql_and

Create a composite Condition object with AND relation.

sql_or

Create a composite Condition object with OR relation.

sql_composite

Create a composite Condition object.

as_string

Converts condition to string

operand

Return expression for passed in operand.

extend_bind_variables
struct_to_condition

Converts passed in data structure to condition object. SQL::Entity::Condition->struct_to_condition(a => 1, b => 3); converts to a = 1 AND b = 3

SQL::Entity::Condition->struct_to_condition(a => 1, b => [1,3]); converts to a = 1 AND b IN (1,3)

SQL::Entity::Condition->struct_to_condition(a => 1, b => {operator => '!=', operand => 3}); converts to a = 1 AND b != 3

SQL::Entity::Condition->struct_to_condition(a => 1, b => {operator => 'LIKE', operand => "'A%'", relation => 'OR'}); coverts to a = 1 OR b LIKE 'A%'

convert_extended_operand

Return operator, operand2, relation for passed in operand

SEE ALSO

SQL::Query SQL::Entity SQL::Entity::Column

COPYRIGHT AND LICENSE

The SQL::Entity::Condition module is free software. You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.

AUTHOR

Adrian Witas, adrian@webapp.strefa.pl