NAME

Fey::Literal::Term - Represents a literal term in a SQL statement

SYNOPSIS

  my $term = Fey::Literal::Term->new(@anything)

DESCRIPTION

This class represents a literal term in a SQL statement. A "term" in this module means a literal term that will be used verbatim, without quoting.

This allows you to create SQL for almost any expression, so that you can something like this EXTRACT( DOY FROM TIMESTAMP User.creation_date ), which is a valid Postgres expression. This would be created like this:

  my $term =
      Fey::Literal::Term->new
          ( 'DOY FROM TIMESTAMP ', $column );

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

This ability to insert arbitrary strings into a SQL statement is meant to be used as a back-door to support any sort of SQL snippet not otherwise supported by the core Fey classes in a more direct manner.

INHERITANCE

This module is a subclass of Fey::Literal.

METHODS

This class provides the following methods:

Fey::Literal::Term->new(@fragments)

This method creates a new Fey::Literal::Term object representing the term passed to the constructor.

More than one argument may be given; they will all be joined together in the generated SQL. For example:

  my $term = Fey::Literal::Term->new( $column, '::text' );

The arguments can be plain scalars, objects with a sql_or_alias() method (columns, tables, etc.) or any object which is overloaded (the assumption being it that it overloads stringification).

$term->term()

Returns the array reference of fragments passed to the constructor.

$term->sql()

$term->sql_with_alias()

$term->sql_or_alias()

Returns the appropriate SQL snippet. Any Fey objects in the term() will have sql() called on them to generate their part of the term.

ROLES

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

Of course, the contents of a given term may not really allow for any of these things, but having this class do these roles means you can freely use a term object in any part of a SQL snippet.

AUTHOR

Dave Rolsky, <autarch@urth.org>

BUGS

See Fey for details on how to report bugs.

COPYRIGHT & LICENSE

Copyright 2006-2009 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.