NAME
SQL::Builder - a structured SQL manipulation interface
VERSION
Version 0.01 ALPHA - this software isn't production-ready yet and the API is likely to change
SYNOPSIS
SQL::Builder is a collection of modules sharing common interfaces for SQL manipulation with the goal of providing maximum reuse and scalability. It is not a SQL abstraction (although it does sort of abstract it out for you), but a structured interface for its manipulation. Because SQL::Builder is a stateful interface, one's SQL is as portable as they write it, with the possibility to traverse a SQL construct at runtime and, for example, convert instances of MySQL's OR operator ("||") with an appropriate "OR", or to replace the standard concatenation operator ("||"), to MySQL's "CONCAT".
This module doesn't have any methods (yet). See SQL::Builder::*
DESCRIPTION
THIS IS CURRENTLY UNSTABLE SOFTWARE. DO NOT USE IT IN PRODUCTION CODE; IT IS STILL UNDERGOING DEVELOPMENT. THE CURRENT TESTS COMPILE AND MOST COULD SHOULD WORK, BUT ALL IS LACKING IN DOCUMENTATION
This module may be "too much" or "unbenefitial" for certain applications. I work on data warehouses which provide interfaces for generating reports, and find the functionality provided by SQL::Builder to be quitessential. Given the dynamics of most applications I've written, I see little reason not to use SQL::Builder because I care about the maintainability of my query logic.
One of my goals was to create structured interfaces for SQL constructs. I started with the most basic constructs, then started combining them to achieve necessary functionality for SQL statements such as SELECT. SQL::Builder::Select is a relatively small module; most of it's functionality has been contributed by underlying modules such as SQL::Builder::GroupBy, SQL::Builder::Join, SQL::Builder::ColumnList, etc. The benefit of the provided granularity should be obvious.
All modules currently inherit from SQL::Builder::Base which provides many methods which makes creating new SQL constructs quick and easy. It also provides a common base for all constructs which makes subclassing them easy, too. I've found that most of my time has been spent creating convenience methods so that one can do more and type less. I tried to keep all database vendors in mind when developing small constructs, but avoided making any assumptions of how constructs can be used together; this hopefully will result in awesome portability.
METHODS
This module doesn't have any methods yet. See one of the modules below. This is only a summary and might not be 100% accurate, definitely see the module for complete documentation
SQL::Builder::Select(3)
- SELECT statements
SQL::Builder::AggregateFunction(3)
- Subclasses Function.pm, no methods implemented: FUNCTION(arg, arg)
SQL::Builder::Any(3)
- Used to represent anything, useful for subclassing
SQL::Builder::Base(3)
- Common base class/API
SQL::Builder::BinaryOp(3)
- Represent binary operators: LHS OP RHS
- Can also do: foo OP bar OP baz OP bang
SQL::Builder::Column(3)
- Represent a SQL column and the table/schema/data to which it belongs
- Produces: "column[.table[.schema|database[. ...]]]"
SQL::Builder::ColumnList(3)
- Used to represent the columns used in a SELECT statement because they
have special semantics. Inherits List.pm
- Produces: anything, anything_possibly_an_alias, blah
SQL::Builder::Distinct(3)
- Used in SELECT statements, maintains ColumnLists
- Produces: DISTINCT [ON(anything [, ...])] [anthing, [...]]
SQL::Builder::Except(3)
- Represents the EXCEPT junction
- Produces: <anything> EXCEPT <anything>
SQL::Builder::FromList(3)
- Represents the list of tables (or anything) used in SELECT
- Produces: FROM anything [, ...] [anything]
SQL::Builder::FromTable(3)
- Represents a table used in a FROM list. Made particularly for
stateful usage of table aliases
- Produces: table [as Alias] [(col_alias [, ...])]
SQL::Builder::Function(3)
- Stateful representation of a function call and its arguments
- Produces: anything(anything [, ...])
SQL::Builder::GroupBy(3)
- Represents GROUP BY anything [, ...]
- See SQL::Builder::Group
SQL::Builder::Having(3)
- The HAVING clause
- Produces: HAVING anything
SQL::Builder::In(3)
- Representation of the IN operator
- Produces: IN(anything [, ...])
SQL::Builder::Intersect(3)
- Another junction representation
- Produces: anything INTERSECT anything
SQL::Builder::Iterator(3)
- An iterator object particularly used for walking SQL constructs
SQL::Builder::Join(3)
- Used to represent any JOIN
- Produces: [anything] JOIN [anything] [ON anything | USING(anything)]
SQL::Builder::JoinGroup(3)
- Maintains a group of JOINs, useful for nested JOINs
- Produces: (anything [\n ...]) AS anything
SQL::Builder::Junction(3)
- A base object for juntions
- Produces: anything anything anything
SQL::Builder::Limit(3)
- LIMIT/OFFSET clause
- Produces: [LIMIT anything] [OFFSET anything]
SQL::Builder::List(3)
- Used for as a common base for anything that represents a list
SQL::Builder::Order(3)
- Represents an item in the list of ORDER BY
- Produces: anything [ASC|DESC]
SQL::Builder::OrderBy(3)
- Represents the list of expressions in ORDER BY
- Produces: ORDER BY anything [, ...]
SQL::Builder::PostfixOp(3)
- Representation of postfix operators (like foo++)
- Produces: anything anything
SQL::Builder::PrefixOp(3)
- Representation of prefix operators (like ++foo)
- Produces: anything anything
SQL::Builder::Select(3)
- Almost everything in a SELECT statement
- Produces: ... see SQL::Builder::Select
SQL::Builder::SubSelect(3)
- Representation of a sub SELECT. This may be badly broken
SQL::Builder::Table(3)
- Representation of a relation and the schema/database to which it
belongs, and its alias
- Produces: table[.anything]
SQL::Builder::Text(3)
- Represents text to be quoted
- Produces NULL if undef or 'escaped_text'
SQL::Builder::UnaryOp(3)
- Base class for PrefixOp and PostfixOp
- Does not produce anything by itself
SQL::Builder::Union(3)
- Represents UNION junction
- Produces: anything UNION anything
SQL::Builder::Using(3)
- Used to represent the USING clause in a JOIN
- Produces: USING(anything [, ...])
SQL::Builder::Where(3)
- Maintains an AND list of expressions
- Produces: WHERE anything
TODO
- Placeholders**
- Fix circular references**
- More convenience methods
- Improved/more tests
- UPDATE, DELETE support
LICENSE
Perl Artistic
AUTHOR
sili@cpan.org -- Feel free to email me with questions, suggestions, etc
SEE ALSO
perl(1) SQL::Builder::Select(3) SQL::Builder::AggregateFunction(3) SQL::Builder::Any(3) SQL::Builder::Base(3) SQL::Builder::BinaryOp(3) SQL::Builder::Column(3) SQL::Builder::ColumnList(3) SQL::Builder::Distinct(3) SQL::Builder::Except(3) SQL::Builder::FromList(3) SQL::Builder::FromTable(3) SQL::Builder::Function(3) SQL::Builder::GroupBy(3) SQL::Builder::Having(3) SQL::Builder::In(3) SQL::Builder::Intersect(3) SQL::Builder::Iterator(3) SQL::Builder::Join(3) SQL::Builder::JoinGroup(3) SQL::Builder::Junction(3) SQL::Builder::Limit(3) SQL::Builder::List(3) SQL::Builder::Order(3) SQL::Builder::OrderBy(3) SQL::Builder::PostfixOp(3) SQL::Builder::PrefixOp(3) SQL::Builder::Select(3) SQL::Builder::SubSelect(3) SQL::Builder::Table(3) SQL::Builder::Text(3) SQL::Builder::UnaryOp(3) SQL::Builder::Union(3) SQL::Builder::Using(3) SQL::Builder::Where(3)
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 345:
'=end' without a target?