Class::ReluctantORM::SQL::Function - Represent a SQL function, aggregator, stored proc, or operator
use Class::ReluctantORM::SQL::Aliases; # Explicit lookup.... my $eq = Function->by_name('='); # not case senstive my $min_arity = $eq->min_inputs; # 2 for '=' # Usually used implicitly.... # This automatically looks up the '=' function by name my $crit = Criterion->new('=', $column, $param); my $crit2 = Criterion->new($func, $column, $param); # Looks up '=' implicitly my $fc1 = FunctionCall->new('=', $column, $param); my $fc2 = FunctionCall->new($func, $column, $param); # Register new custom functions Function->register( name => 'froobulate', min_inputs => 2, max_inputs => 43, is_associative => 1, is_cummutative => 1, ); # Now... my $crit = Criterion->new('froobulate', $column, $param); # Note: your driver must know how to render froobulate! # List functions my @funcs = Function->list_all_functions(); my @funcs = Function->list_default_functions(); my @funcs = Function->list_aggregate_functions();
Registry for functions, operators, and stored procedures, so that they may be represented in an abstract SQL tree.
Each individual function is treated as a singleton by name; so if you request (explicitly or implicitly) the '=' operator two different times, you will get the same object both times.
A fair number of functions are pre-registered, including = < > AND OR NOT. You can get the complete list by calling Function->list_default_functions().
A Function object represents _which_ function is being referred to. To actually call a function in an abstract SQL tree, create a FunctionCall object.
Searches for a function with the name given, and returns it. Throws an exception if no such function has been registered.
The search is case-insensitive.
Returns true if the function name is registered.
Registers a new Function. After this, you can explicitly or implicitly refer to the function by name.
Options:
Required string, may be symbols. Must be unique - no other registered Function may have the same name.
Required positive integer. Minimum number of arguments the function takes.
Optional positive integer. If not provided, Function is assumed to have no limit.
Optional boolean, default false. If true, marks this function as an aggregrate function.
Optional boolean, default false. If true, indicates CRO can re-group multiple invocations of this function. So, (1+2)+3 = 1+(2+3).
Optional boolean, default false. If true, indicates CRO can re-order arguments of this function. So, 1+2 = 2+1.
Returns an array of all registered functions.
Returns an array of all functions that are provided by default, and guarenteed to be renderable by all drivers.
Returns an array of all aggregate functions.
Returns the name of the Function. Always available and always unique.
Returns the minimum number of inputs the function accepts. Always available.
Returns the maximum number of inputs the function accepts. May be undef, in which case the function has no upper limit on the number of inputs. May also be zero, as for NOW().
Returns true if the function is part of the default kit, which all drivers are required to be able to render. Returns false if the Function was registered by you.
Returns true if the function is an aggregate function, like COUNT or MAX. These functions may only be used in output column expressions, and alter the semantics of the query.
Sine each function is a singleton, it doesn't make sense to clone them. This method thus returns the original, and is provided for consistency with other SQL objects.
To install Class::ReluctantORM, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::ReluctantORM
CPAN shell
perl -MCPAN -e shell install Class::ReluctantORM
For more information on module installation, please visit the detailed CPAN module installation guide.