Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missed index type on Phalcon\Db\Adapter\Pdo\Sqlite::describeIndexes #10997

Closed
sergeyklay opened this issue Oct 4, 2015 · 2 comments
Closed

Comments

@sergeyklay
Copy link
Member

How to reproduce:

SH

sqlite3 test1.db

SQL

CREATE TABLE COMPANY(
   ID INT PRIMARY KEY     NOT NULL,
   NAME           TEXT    NOT NULL,
   AGE            INT     NOT NULL,
   ADDRESS        CHAR(50),
   SALARY         REAL
);

CREATE INDEX salary_index ON COMPANY (salary);
CREATE UNIQUE INDEX name_index ON COMPANY (name);

PHP

<?php
use Phalcon\Db\Adapter\Pdo\Sqlite;

$connection = new Sqlite(['dbname' => dirname(__FILE__) . '/test1.db']);
$indexes    = $connection->describeIndexes('company');

echo print_r($indexes, true), PHP_EOL;

Actual

Array
(
    [name_index] => Phalcon\Db\Index Object
        (
            [_name:protected] => name_index
            [_columns:protected] => Array
                (
                    [0] => NAME
                )

            [_type:protected] =>
        )

    [salary_index] => Phalcon\Db\Index Object
        (
            [_name:protected] => salary_index
            [_columns:protected] => Array
                (
                    [0] => SALARY
                )

            [_type:protected] =>
        )

    [sqlite_autoindex_COMPANY_1] => Phalcon\Db\Index Object
        (
            [_name:protected] => sqlite_autoindex_COMPANY_1
            [_columns:protected] => Array
                (
                    [0] => ID
                )

            [_type:protected] =>
        )

)

Expected

Array
(
    [name_index] => Phalcon\Db\Index Object
        (
            [_name:protected] => name_index
            [_columns:protected] => Array
                (
                    [0] => NAME
                )

            [_type:protected] => 'PRIMARY'
        )

    [salary_index] => Phalcon\Db\Index Object
        (
            [_name:protected] => salary_index
            [_columns:protected] => Array
                (
                    [0] => SALARY
                )

            [_type:protected] =>
        )

    [sqlite_autoindex_COMPANY_1] => Phalcon\Db\Index Object
        (
            [_name:protected] => sqlite_autoindex_COMPANY_1
            [_columns:protected] => Array
                (
                    [0] => ID
                )

            [_type:protected] => 'UNIQUE'
        )

)

SQLite

.header on
.mode column
.width 26 8 48

SELECT name, rootpage, sql FROM sqlite_master WHERE type = 'index' AND tbl_name = 'COMPANY';

name                        rootpage  sql
--------------------------  --------  ------------------------------------------------
sqlite_autoindex_COMPANY_1  3
salary_index                6         CREATE INDEX salary_index ON COMPANY (salary)
name_index                  7         CREATE UNIQUE INDEX name_index ON COMPANY (name)
@sergeyklay
Copy link
Member Author

refs phalcon/phalcon-devtools#518

@sergeyklay
Copy link
Member Author

Fixed in #10998

pantaovay pushed a commit to pantaovay/cphalcon that referenced this issue Nov 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant