1 package # Hide from PAUSE
2 DBIx::Class::SQLMaker::Pg;
4 use base qw( DBIx::Class::SQLMaker );
5 use Carp::Clan qw/^DBIx::Class|^SQL::Abstract/;
7 sub _datetime_now_sql { 'NOW()' }
13 day_of_month => 'DAY',
16 seconds_since_epoch => 'EPOCH',
18 iso_day_of_week => 'ISODOW',
19 iso_year => 'ISOYEAR',
20 microsecond => 'MICROSECONDS',
21 millenium => 'MILLENIUM',
22 millisecond => 'MILLISECONDS',
27 timezone => 'TIMEZONE',
28 timezone_hour => 'TIMEZONE_HOUR',
29 timezone_minute => 'TIMEZONE_MINUTE',
34 my %diff_part_map = %part_map;
35 $diff_part_map{day} = delete $diff_part_map{day_of_month};
38 die $_[0]->_unsupported_date_extraction($_[1], 'PostgreSQL')
39 unless exists $part_map{$_[1]};
40 "EXTRACT($part_map{$_[1]} FROM $_[2])"
42 sub _datetime_diff_sql {
43 die $_[0]->_unsupported_date_diff($_[1], 'PostgreSQL')
44 unless exists $diff_part_map{$_[1]};
45 "EXTRACT($diff_part_map{$_[1]} FROM ($_[2] - $_[3]))"
48 sub _reorder_add_datetime_vars {
49 my ($self, $amount, $date) = @_;
51 return ($date, $amount);
54 sub _datetime_add_sql {
55 my ($self, $part, $date, $amount) = @_;
57 die $self->_unsupported_date_adding($part, 'PostgreSQL')
58 unless exists $diff_part_map{$part};
60 return "($date + $amount || ' $part_map{$part}'))"
64 =head1 DATE FUNCTION IMPLEMENTATION
66 The function used to extract date information is C<EXTRACT>, which supports
90 The function used to diff dates is subtraction and C<EXTRACT>, which supports