Alzabo

 view release on metacpan or  search on metacpan

lib/Alzabo/SQLMaker/PostgreSQL.pm  view on Meta::CPAN

		       $_->[3] ? ( format => $_->[3] ) : (),
		     );
    }

    foreach ( [ RPAD => [0,0,1], [ 'string' ] ],
	      [ LPAD => [0,0,1], [ 'string' ] ],
	      [ SUBSTR => [0,0,0], [ 'string' ] ],
	    )
    {
	make_function( function => $_->[0],
		       min => 2,
		       max => 3,
		       quote => $_->[1],
		       groups => $_->[2],
		     );
    }

    make_function( function => 'COALESCE',
		   min => 2,
		   max => undef,
		   quote => [0,0,0],
		   groups => [ 'control' ],
		 );

    make_function( function => 'OVERLAPS',
		   min => 4,
		   max => 4,
		   quote  => [1,1,1,1],
		   groups => [ 'datetime' ],
		 );

    foreach ( [ COUNT  => [0], [ 'aggregate', 'common' ] ],
	      [ AVG  => [0], [ 'aggregate', 'common' ] ],
	      [ MIN  => [0], [ 'aggregate', 'common' ] ],
	      [ MAX  => [0], [ 'aggregate', 'common' ] ],
	      [ SUM  => [0], [ 'aggregate', 'common' ] ],
	      [ STDDEV  => [0], [ 'aggregate' ] ],
	      [ VARIANCE => [0], [ 'aggregate' ] ],

	      [ DISTINCT => [0], [ 'common' ] ],
	    )
    {
	make_function( function => $_->[0],
		       min => 1,
		       max => 1,
		       quote => $_->[1],
		       groups => $_->[2],
		     );
    }

    $MADE_FUNCTIONS = 1;
}

sub init
{
    1;
}

sub new
{
    my $self = shift->SUPER::new(@_);

    $self->{alias_in_having} = 0;

    return $self;
}

sub limit
{
    my $self = shift;
    my ($max, $offset) = @_;

    $self->_assert_last_op( qw( from function where and or condition order_by group_by ) );

    $self->{sql} .= " LIMIT $max";
    $self->{sql} .= " OFFSET $offset" if $offset;

    $self->{last_op} = 'limit';

    return $self;
}

sub get_limit
{
    return undef;
}

sub distinct_requires_order_by_in_select { 1 }

sub sqlmaker_id
{
    return 'PostgreSQL';
}

1;

__END__

=head1 NAME

Alzabo::SQLMaker::PostgreSQL - Alzabo SQL making class for PostgreSQL

=head1 SYNOPSIS

  use Alzabo::SQLMaker;

  my $sql = Alzabo::SQLMaker->new( sql => 'PostgreSQL' );

=head1 DESCRIPTION

PostgreSQL-specific SQL creation.

=head1 METHODS

Almost all of the functionality inherited from C<Alzabo::SQLMaker> as
is.  The only overridden methods are C<limit()> and C<get_limit()>, as
PostgreSQL does allow for a C<LIMIT> clause in its SQL.

=head1 EXPORTED SQL FUNCTIONS

SQL may be imported by name or by tags.  They take arguments as



( run in 0.367 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )