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

NAME

Fey::Literal::Function - Represents a literal function in a SQL statement

SYNOPSIS

  my $function = Fey::Literal::Function->new( 'LENGTH', $column );

DESCRIPTION

This class represents a literal function in a SQL statement, such as NOW() or LENGTH(User.username).

INHERITANCE

This module is a subclass of Fey::Literal.

METHODS

This class provides the following methods:

Fey::Literal::Function->new( $function, @args )

This method creates a new Fey::Literal::Function object.

It requires at least one argument, which is the name of the SQL function that this literal represents. It can accept any number of additional optional arguments. These arguments must be either scalars, literals, or columns which belong to a table.

Any scalars passed in as arguments will be passed in turn to Fey::Literal->new_from_scalar().

$function->set_alias_name($alias)

Use this to explicitly set a function's alias name for use in SQL. If you don't set this it will be autogenerated as needed.

$function->function()

The function's name, as passed to the constructor.

$function->args()

Returns an array reference of the function's arguments, as passed to the constructor.

$function->sql()

$function->sql_with_alias()

$function->sql_or_alias()

Returns the appropriate SQL snippet.

Calling $function->sql_with_alias() causes a unique alias for the function to be created.

ROLES

This class does the Fey::Role::Selectable, Fey::Role::Comparable, Fey::Role::Groupable, and Fey::Role::Orderable roles.

This class overrides the is_groupable() and is_orderable() methods so that they only return true if the $function->sql_with_alias() has been called previously. This function is called when a function is used in the SELECT clause of a query. A function must be used in a SELECT in order to be used in a GROUP BY or ORDER BY clause.

AUTHOR

Dave Rolsky, <autarch@urth.org>

BUGS

See Fey for details on how to report bugs.

COPYRIGHT & LICENSE

Copyright 2006-2008 Dave Rolsky, All Rights Reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.