Fey::Literal::Function(3)

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

VERSION
version 0.44

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->id()
The id for a function is uniquely identifies the function.

  $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", "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.

BUGS
See Fey for details on how to report bugs.

Bugs may be submitted at <https://github.com/ap/Fey/issues>.

SOURCE
The source code repository for Fey can be found at <https://github.com/ap/Fey>.

AUTHOR
Dave Rolsky <autarch@urth.org>

COPYRIGHT AND LICENSE
This software is Copyright (c) 2011 - 2025 by Dave Rolsky.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)

The full text of the license can be found in the LICENSE file included with this distribution.