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


version 0.43


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


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


This module is a subclass of Fey::Literal.


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().


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.


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


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


The id for a function is uniquely identifies the function.




Returns the appropriate SQL snippet.

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


This class does the Fey::Role::Selectable, Fey::Role::Comparable, Fey::Role::Groupable, Fey::Role::Orderable, and Fey::Role::HasAliasName 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.


See Fey for details on how to report bugs.


Dave Rolsky <>


This software is Copyright (c) 2011 - 2015 by Dave Rolsky.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)