DBD-mysql icon indicating copy to clipboard operation
DBD-mysql copied to clipboard

Curious behaviour with serial and primary_key method [rt.cpan.org #77952]

Open mbeijen opened this issue 8 years ago • 0 comments
trafficstars

Migrated from rt.cpan.org#77952 (status was 'new')

Requestors:

From [email protected] on 2012-06-21 20:26:32:

First table definition:

create table delivery_lists (
   code serial,
   created datetime not null
);

Second table definition:

create table delivery_lists (
   code serial,
   created datetime not null,
   primary key(code)
);

MySQL shows in both cases:

mysql> describe delivery_lists;
+---------+---------------------+------+-----+---------+----------------
+
| Field   | Type                | Null | Key | Default | Extra          
|
+---------+---------------------+------+-----+---------+----------------
+
| code    | bigint(20) unsigned | NO   | PRI | NULL    | auto_increment 
|
| created | datetime            | NO   |     | NULL    |                
|
+---------+---------------------+------+-----+---------+----------------
+
2 rows in set (0.00 sec)

primary_key method yields different results in these two cases:

 @keys = $self->{dbh}->primary_key(undef, undef, 'delivery_tables);

First case: @keys = ('code');

Second case: @keys = ();

That differs from what MySQL is showing.

Please advise.

Regards
          Racke

mbeijen avatar Nov 14 '17 19:11 mbeijen