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

[1.3.1] Phalcon ORM consider tinyint as boolean #2236

Closed
ogarbe opened this issue Mar 26, 2014 · 3 comments
Closed

[1.3.1] Phalcon ORM consider tinyint as boolean #2236

ogarbe opened this issue Mar 26, 2014 · 3 comments

Comments

@ogarbe
Copy link
Contributor

ogarbe commented Mar 26, 2014

Hello we've got a big pb with Phalcon 1.3.1 vs Phalcon 1.2.6

Our Model which contains tinyint values is now broken as values are now saved as 0 / 1 (true / false) even if they're set to 2 / 3 ....

0 => false (in the model) => 0 (in db)
1 .... 5 => true (in the model) => 1 (in db).

@ogarbe
Copy link
Contributor Author

ogarbe commented Mar 26, 2014

We use the Introspection metadata system, here is a sample of :

CREATE TABLE IF NOT EXISTS `member` (
  `id_membre` int(10) unsigned NOT NULL AUTO_INCREMENT,
...
  `flag_update` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0 : update all, 1 : updated, 2 : update last connexion only',
...
  PRIMARY KEY (`id_membre`),
 ...
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=17314546 ;
$metadata = $this->getDI()->get('modelsMetadata');
        var_dump($metadata->getDataTypes($this));
        die('die');

and here the result

array (size=16)
  'id_membre' => int 0
...
  'flag_update' => int 8
...

die

as you can find, flag_update datatype is 8 which is boolean instead of being int (datatype 0).

@ogarbe
Copy link
Contributor Author

ogarbe commented Mar 26, 2014

In fact the pb seems weirder, in 1.2.6 flag_update is already as an boolean type, but as it was'nt cast into false / true, the pb was unseen.

@ogarbe
Copy link
Contributor Author

ogarbe commented Mar 26, 2014

The problem is here :
https://github.com/phalcon/cphalcon/blob/1.3.1/ext/db/adapter/pdo/mysql.c#L221-L227

tinyint(1) is put as a boolean whereas it can be between 0 to 127

ogarbe added a commit to ogarbe/cphalcon that referenced this issue Mar 26, 2014
phalcon pushed a commit that referenced this issue Mar 31, 2014
Fixes #2236 - in mysql tinyint(1) is not boolean
@ogarbe ogarbe closed this as completed Apr 9, 2014
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

2 participants