Tree::Predicate - a balanced, splittable tree for SQL predicates
Version 0.03
Tree::Predicate allows the composition of a tree of SQL predicates that can then be "split" into UNION-able predicats that do not contain an OR.
use Tree::Predicate qw(:logical); my $left_branch = OR('a', 'b'); my $right_branch = OR('c', 'd'); my $tree = AND($left_branch, $right_branch); print $tree->as_string; # ((a OR b) AND (c OR d)) my @trees = $tree->split; # four trees # (a AND c) # (a AND d) # (b AND c) # (b AND d) $tree->negate; print $tree->as_string; # ((NOT(a) AND NOT(b)) OR (NOT(c) AND NOT(d)))
AND/OR/NOT may be individually imported, or they may be collectively imported with :logical.
expresses the tree as a string suitable for including in SQL
negates the tree
returns a list (or reference) of the tree's operands, for whatever you might want that
returns a list of subtrees that can be used in a UNION statement to produce a logically equivalent query.
dies if number of children exceeds SPLIT_LIMIT
constructors for trees
David Marshall, <dmarshal at yahoo-inc.com>
<dmarshal at yahoo-inc.com>
Please report any bugs or feature requests to bug-tree-predicate at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Tree-Predicate. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-tree-predicate at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Tree::Predicate
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Tree-Predicate
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Tree-Predicate
CPAN Ratings
http://cpanratings.perl.org/d/Tree-Predicate
Search CPAN
http://search.cpan.org/dist/Tree-Predicate/
Copyright 2009 Yahoo! Inc., all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Tree::Predicate, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tree::Predicate
CPAN shell
perl -MCPAN -e shell install Tree::Predicate
For more information on module installation, please visit the detailed CPAN module installation guide.