Dave Rolsky > Fey-0.17 > Fey::Literal::Term

Download:
Fey-0.17.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  2
Open  0
View Bugs
Report a bug
Source   Latest Release: Fey-0.34

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->sql_or_alias( $sql->dbh() ) );

  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 ma

INHERITANCE ^

This module is a subclass of Fey::Literal.

METHODS ^

This class provides the following methods:

Fey::Literal::Term->new($term)

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

$term->term()

Returns the term as passed to the constructor.

$term->sql()

$term->sql_with_alias()

$term->sql_or_alias()

Returns the appropriate SQL snippet.

ROLES ^

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