-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[BUG]: Column::TYPE_BINARY and Column::TYPE_TINYINTEGER are both 26 #16532
Comments
The biggest issue is when we are using casting (i.e. castOnHydrate) it will convert my binary into a int because it found the wrong type. Since I don't want to turn off casting on hydrate, and want to fix the bind type, tis is my temporary solution for now. I made my own Mysql adapter to get around the issue affected by the wrong Column type value. use Phalcon\Db\Column;
class Mysql extends \Phalcon\Db\Adapter\Pdo\Mysql
{
public function describeColumns(string $table, string $schema = null): array
{
$definitions = parent::describeColumns($table, $schema);
if (Column::TYPE_TINYINTEGER !== Column::TYPE_BINARY) {
return $definitions;
}
foreach ($definitions as $key => $definition) {
if ($definition->getType() === Column::TYPE_TINYINTEGER && !$definition->isNumeric()) {
// probably a binary at this point
$newDefinition = [];
// protected to public
$prefix = chr(0).'*'.chr(0);
foreach ((array)$definition as $k => $value) {
$newDefinition[str_replace($prefix, '', $k)] = $value;
}
$newDefinition['bindType'] = Column::BIND_PARAM_BLOB;
$newDefinition['type'] = Column::TYPE_VARBINARY;
unset($newDefinition['scale']);
// reset definition
$definitions[$key] = new Column($definition->getName(), $newDefinition);
}
}
return $definitions;
}
} |
… because it breaks the mysql binary and varbinary fields phalcon/cphalcon#16532
Hi, according to the release notes for version 5.7.0 this fix was included, however I've installed 5.7.0 and still have the issue.
And this is the result:
I installed Phalcon from the remi repo using yum:
|
I am not sure about 5.7 but 5.8 has the correct code https://github.com/phalcon/cphalcon/blob/5.0.x/phalcon/Db/Column.zep#L87 |
Should I install through PECL instead of yum and remi repo? |
You can give it a try. I am pretty sure that Remi already has v5.8 but in any case, give it a go with PECL and let us know |
Describe the bug
Phalcon\Db\Column::TYPE_BINARY and Phalcon\Db\Column::TYPE_TINYINTEGER should not be equal
To Reproduce
Expected behavior
Additional context
Column::TYPE_BINARY is not numeric
Column::TYPE_TINYINTEGER is numeric
Missing unit test for TYPE_BINARY
The text was updated successfully, but these errors were encountered: