NAME

SQL::Entity::Index - Entity index abstraction.

SYNOPSIS

use SQL::Entity::Index;

my $index = SQL::Entity::Index->new(
    name    => 'idx_empno',
    columns => ['empno'],
    hint    => ' INDEX_ASC( emp empno ) '
);

DESCRIPTION

Represents index, that force resultset order by either generating ORDER BY sql fragment,
or by adding hint sql fragement (Oracle, MySQL)


my $entity = SQL::Entity->new(
    name                  => 'emp',
    primary_key           => ['empno'],
    unique_expression     => 'rowid',
    columns               => [
        sql_column(name => 'ename'),
        sql_column(name => 'empno'),
        sql_column(name => 'deptno')
    ],
    indexes => [
        sql_index(name => 'idx_emp_empno', columns => ['empno'], hint => 'INDEX_ASC(emp idx_emp_empno)'),
        sql_index(name => 'idx_emp_ename', columns => ['ename']),
    ],
    order_index => 'idx_emp_ename'
);


my ($sql, $bind_variables) = $query->query();
will return
SELECT emp.*
FROM (
SELECT /*+ INDEX_ASC(emp idx_emp_ename) */ ROWNUM AS the_rownum,
  emp.rowid AS the_rowid,
  emp.deptno,
  emp.ename,
  emp.empno
FROM emp
WHERE ROWNUM < ?) emp
WHERE the_rownum >=

EXPORT

sql_index by 'all' tag.

ATTRIBUTES

name
order_by_cluase

order_by_cluase => 'empno desc, ename asc'

columns
hint

Cost base optymizer hitn (Oracle, MySQL)

#TODO add dybnamic hint based on condition objects

METHODS

sql_index

Creates a new instance of the SQL::Entity::Index

order_by_operand

Returns sql fragment operand to ORDER BY cluase

SEE ALSO

SQL::Entity SQL::Entity::Column

COPYRIGHT AND LICENSE

The SQL::Entity::Index 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