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

Issue 14691 #14692

Merged
merged 7 commits into from
Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Fixed `Phalcon\Mvc\Model::__set` to return a more informative message if we are tying to access a non visible property [#13518](https://github.com/phalcon/cphalcon/issues/13518) [#13900](https://github.com/phalcon/cphalcon/issues/13900)
- Fixed `Phalcon\Mvc\Model\Resultset\Simple::toArray` to correctly process virtual fields [#14669](https://github.com/phalcon/cphalcon/issues/14669)
- Fixed `Phalcon\Session\Manager::getUniqueKey` to prefix the key only if `uniqueId` is present [#14688](https://github.com/phalcon/cphalcon/issues/14688)
- Fixed `Phalcon\Db\Adapter\Pdo::describeColumns` to correctly detect ENUM columns [#14691](https://github.com/phalcon/cphalcon/issues/14691)

# [4.0.0](https://github.com/phalcon/cphalcon/releases/tag/v4.0.0) (2019-12-21)

Expand Down
52 changes: 26 additions & 26 deletions phalcon/Db/Adapter/Pdo/Mysql.zep
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class Mysql extends PdoAdapter
/**
* BOOL
*/
case memstr(columnType, "tinyint(1)"):
case starts_with(columnType, "tinyint(1)", true):
/**
* tinyint(1) is boolean
*/
Expand All @@ -149,7 +149,7 @@ class Mysql extends PdoAdapter
/**
* BIGINT
*/
case memstr(columnType, "bigint"):
case starts_with(columnType, "bigint", true):
let definition["type"] = Column::TYPE_BIGINTEGER,
definition["isNumeric"] = true,
definition["bindType"] = Column::BIND_PARAM_INT;
Expand All @@ -159,7 +159,7 @@ class Mysql extends PdoAdapter
/**
* MEDIUMINT
*/
case memstr(columnType, "mediumint"):
case starts_with(columnType, "mediumint", true):
let definition["type"] = Column::TYPE_MEDIUMINTEGER,
definition["isNumeric"] = true,
definition["bindType"] = Column::BIND_PARAM_INT;
Expand All @@ -169,7 +169,7 @@ class Mysql extends PdoAdapter
/**
* SMALLINT
*/
case memstr(columnType, "smallint"):
case starts_with(columnType, "smallint", true):
let definition["type"] = Column::TYPE_SMALLINTEGER,
definition["isNumeric"] = true,
definition["bindType"] = Column::BIND_PARAM_INT;
Expand All @@ -179,7 +179,7 @@ class Mysql extends PdoAdapter
/**
* TINYINT
*/
case memstr(columnType, "tinyint"):
case starts_with(columnType, "tinyint", true):
/**
* Smallint/Bigint/Integers/Int are int
*/
Expand All @@ -192,7 +192,7 @@ class Mysql extends PdoAdapter
/**
* INT
*/
case memstr(columnType, "int"):
case starts_with(columnType, "int", true):
let definition["type"] = Column::TYPE_INTEGER,
definition["isNumeric"] = true,
definition["bindType"] = Column::BIND_PARAM_INT;
Expand All @@ -202,7 +202,7 @@ class Mysql extends PdoAdapter
/**
* BIT
*/
case memstr(columnType, "bit"):
case starts_with(columnType, "bit", true):
let definition["type"] = Column::TYPE_BIT,
definition["bindType"] = Column::BIND_PARAM_INT;

Expand All @@ -211,23 +211,23 @@ class Mysql extends PdoAdapter
/**
* ENUM
*/
case memstr(columnType, "enum"):
case starts_with(columnType, "enum", true):
let definition["type"] = Column::TYPE_ENUM;

break;

/**
* DATE
*/
case memstr(columnType, "datetime"):
case starts_with(columnType, "datetime", true):
let definition["type"] = Column::TYPE_DATETIME;

break;

/**
* DATETIME
*/
case memstr(columnType, "date"):
case starts_with(columnType, "date", true):
let definition["type"] = Column::TYPE_DATE;

break;
Expand All @@ -236,7 +236,7 @@ class Mysql extends PdoAdapter
* DECIMAL - This will need to be a string so as not to lose
* the decimals
*/
case memstr(columnType, "decimal"):
case starts_with(columnType, "decimal", true):
let definition["type"] = Column::TYPE_DECIMAL,
definition["isNumeric"] = true;

Expand All @@ -245,7 +245,7 @@ class Mysql extends PdoAdapter
/**
* DOUBLE
*/
case memstr(columnType, "double"):
case starts_with(columnType, "double", true):
let definition["type"] = Column::TYPE_DOUBLE,
definition["isNumeric"] = true,
definition["bindType"] = Column::BIND_PARAM_DECIMAL;
Expand All @@ -255,7 +255,7 @@ class Mysql extends PdoAdapter
/**
* FLOAT
*/
case memstr(columnType, "float"):
case starts_with(columnType, "float", true):
let definition["type"] = Column::TYPE_FLOAT,
definition["isNumeric"] = true,
definition["bindType"] = Column::BIND_PARAM_DECIMAL;
Expand All @@ -265,103 +265,103 @@ class Mysql extends PdoAdapter
/**
* MEDIUMBLOB
*/
case memstr(columnType, "mediumblob"):
case starts_with(columnType, "mediumblob", true):
let definition["type"] = Column::TYPE_MEDIUMBLOB;

break;

/**
* LONGBLOB
*/
case memstr(columnType, "longblob"):
case starts_with(columnType, "longblob", true):
let definition["type"] = Column::TYPE_LONGBLOB;

break;

/**
* TINYBLOB
*/
case memstr(columnType, "tinyblob"):
case starts_with(columnType, "tinyblob", true):
let definition["type"] = Column::TYPE_TINYBLOB;

break;

/**
* BLOB
*/
case memstr(columnType, "blob"):
case starts_with(columnType, "blob", true):
let definition["type"] = Column::TYPE_BLOB;

break;

/**
* TIMESTAMP
*/
case memstr(columnType, "timestamp"):
case starts_with(columnType, "timestamp", true):
let definition["type"] = Column::TYPE_TIMESTAMP;

break;

/**
* TIME
*/
case memstr(columnType, "time"):
case starts_with(columnType, "time", true):
let definition["type"] = Column::TYPE_TIME;

break;

/**
* JSON
*/
case memstr(columnType, "json"):
case starts_with(columnType, "json", true):
let definition["type"] = Column::TYPE_JSON;

break;

/**
* LONGTEXT
*/
case memstr(columnType, "longtext"):
case starts_with(columnType, "longtext", true):
let definition["type"] = Column::TYPE_LONGTEXT;

break;

/**
* MEDIUMTEXT
*/
case memstr(columnType, "mediumtext"):
case starts_with(columnType, "mediumtext", true):
let definition["type"] = Column::TYPE_MEDIUMTEXT;

break;

/**
* TINYTEXT
*/
case memstr(columnType, "tinytext"):
case starts_with(columnType, "tinytext", true):
let definition["type"] = Column::TYPE_TINYTEXT;

break;

/**
* TEXT
*/
case memstr(columnType, "text"):
case starts_with(columnType, "text", true):
let definition["type"] = Column::TYPE_TEXT;

break;

/**
* VARCHAR
*/
case memstr(columnType, "varchar"):
case starts_with(columnType, "varchar", true):
let definition["type"] = Column::TYPE_VARCHAR;

break;

/**
* CHAR
*/
case memstr(columnType, "char"):
case starts_with(columnType, "char", true):
let definition["type"] = Column::TYPE_CHAR;

break;
Expand Down
2 changes: 1 addition & 1 deletion tests/_data/assets/db/schemas/mysql_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12735,7 +12735,7 @@ create table dialect_table
field_char_default char(10) default 'ABC' null,
field_decimal decimal(10,4) null,
field_decimal_default decimal(10,4) default 14.5678 null,
field_enum enum('xs', 's', 'm', 'l', 'xl') null,
field_enum enum('xs', 's', 'm', 'l', 'xl', 'internal') null,
field_integer int(10) null,
field_integer_default int(10) default 1 null,
field_json json null,
Expand Down
2 changes: 1 addition & 1 deletion tests/_data/fixtures/Traits/Db/MysqlTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ protected function getColumns(): array
'columnName' => 'field_enum',
'type' => Column::TYPE_ENUM,
'isNumeric' => false,
'size' => "'xs','s','m','l','xl'",
'size' => "'xs','s','m','l','xl','internal'",
'default' => null,
'unsigned' => false,
'notNull' => false,
Expand Down