Skip to content

Missed index type on Phalcon\Db\Adapter\Pdo\Mysql::describeIndexes #11036

Closed
@sergeyklay

Description

@sergeyklay

How to reproduce:

SQL

CREATE TABLE `tokens` (
  `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `token` VARCHAR(100) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `token_UNIQUE` (`token`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

PHP

<?php

use Phalcon\Db\Adapter\Pdo\Mysql;

$connection = new Mysql(
    [
        'host'        => 'localhost',
        'username'    => 'root',
        'password'    => '',
        'dbname'      => 'test',
        'charset'     => 'utf8',
    ]
);

$indexes = $connection->describeIndexes('tokens');

foreach ($indexes as $index) {
    var_dump($index->getType());
}

Actual

string(0) ""
string(0) ""

Expected

string(7) "PRIMARY"
string(6) "UNIQUE"

MySQL

mysql> SHOW INDEXES FROM `tokens`\G
*************************** 1. row ***************************
        Table: tokens
   Non_unique: 0
     Key_name: PRIMARY
 Seq_in_index: 1
  Column_name: id
    Collation: A
  Cardinality: 0
     Sub_part: NULL
       Packed: NULL
         Null: 
   Index_type: BTREE
      Comment: 
Index_comment: 
*************************** 2. row ***************************
        Table: tokens
   Non_unique: 0
     Key_name: token_UNIQUE
 Seq_in_index: 1
  Column_name: token
    Collation: A
  Cardinality: 0
     Sub_part: NULL
       Packed: NULL
         Null: 
   Index_type: BTREE
      Comment: 
Index_comment: 
2 rows in set (0.01 sec)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions