-
-
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
Labels
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;
}
} |
jturbide
added a commit
to zemit-cms/core
that referenced
this issue
Feb 20, 2024
jturbide
added a commit
to zemit-cms/core
that referenced
this issue
Feb 20, 2024
… because it breaks the mysql binary and varbinary fields phalcon/cphalcon#16532
niden
added
status: medium
Medium
5.0
The issues we want to solve in the 5.0 release
and removed
status: unverified
Unverified
labels
Apr 5, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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: