nekokak/p5-Teng — pull request #117 by astj (2013-09-22 17:40:08+00:00)
Title: fix problem when column name of primary key is not 'id' with DBD::Pg

In following condition, Teng::Insert fails.
* Using with PostgreSQL
* Primary key is not the column named "id" ( i.e. "table_id" fails )

So I wrote the patch.

In this patch, `_last_insert_id` does not pass the table's sequence name as `{ sequence => ...}` to `DBD::Pg::last_insert_id`.
Alternatively, it passes simply the table's name as `$tablename`.

### Reproducing conditions of this problem

#### Schema to reproduce
```sql
CREATE TABLE IF NOT EXISTS entry (
entry_id SERIAL PRIMARY KEY,
body varchar(255) not null
);
```

#### Code to reproduce
```perl
my $db = My::DB->new({connect_info => ["dbi:Pg:dbname=$dbname;host=$host;port=$port", "$username", "$password",]});

say $db->fast_insert( entry => +{ body => 'hello', } );
```

#### Expected Results
```
(Some numeric ID)
```

#### Actual Results
```
DBD::Pg::db last_insert_id failed: ERROR: relation "entry_id_seq" does not exist at /Users/asato/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/Teng.pm line 289.
```