|
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 | |
|---|
| 3 | package Data::ObjectDriver::Driver::DBI::Pg; |
|---|
| 4 | use strict; |
|---|
| 5 | use base qw( Data::ObjectDriver::Driver::DBI ); |
|---|
| 6 | |
|---|
| 7 | sub init_db { |
|---|
| 8 | my $driver = shift; |
|---|
| 9 | my $dbh = $driver->SUPER::init_db(@_); |
|---|
| 10 | $dbh->do("set timezone to 'UTC'"); |
|---|
| 11 | $dbh; |
|---|
| 12 | } |
|---|
| 13 | |
|---|
| 14 | sub 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 | |
|---|
| 22 | sub sequence_name { |
|---|
| 23 | my $driver = shift; |
|---|
| 24 | my($class) = @_; |
|---|
| 25 | return join '_', $class->datasource, 'seq'; |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | sub 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 | |
|---|
| 35 | 1; |
|---|