root/trunk/lib/Data/ObjectDriver/Driver/DBI/Pg.pm @ 7

Revision 7, 0.7 kB (checked in by sky, 4 years ago)

r10@crucially-3 (orig r927): btrott | 2005-06-23 15:56:28 -0700
Changed to assume use of SERIAL columns, which auto-generate IDs for us

  • Property svn:keywords set to Id Revision
Line 
1# $Id$
2
3package Data::ObjectDriver::Driver::DBI::Pg;
4use strict;
5use base qw( Data::ObjectDriver::Driver::DBI );
6
7sub init_db {
8    my $driver = shift;
9    my $dbh = $driver->SUPER::init_db(@_);
10    $dbh->do("set timezone to 'UTC'");
11    $dbh;
12}
13
14sub bind_param_attributes {
15    my ($driver, $data_type) = @_;
16    if ($data_type && $data_type eq 'blob') {
17        return { pg_type => DBD::Pg::PG_BYTEA() };
18    }
19    return undef;
20}
21
22sub sequence_name {
23    my $driver = shift;
24    my($class) = @_;
25    return join '_', $class->datasource, 'seq';
26}
27
28sub fetch_id {
29    my $driver = shift;
30    my($dbh, $sth) = @_;
31    $dbh->last_insert_id(undef, undef, undef, undef,
32        { sequence => $driver->sequence_name });
33}
34
351;
Note: See TracBrowser for help on using the browser.