[DDC-1967] mysql Tiny ints not behaving properley Created: 04/Aug/12  Updated: 10/Oct/12  Resolved: 10/Oct/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.2.2
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: Jonathan Robinson Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None
Environment:

mysql 5.1.58, php 5.3



 Description   

If I set up a field as a tinyint lets say called bob. I then extract a record.

If I do $object->getBob() - when bob = 1, everything works fine.

However, if I do $object->getBob() when bob = 0, the null value is returned.

If bob is null, everything works fine.

This issues only seems to happen with mysql tinyint.



 Comments   
Comment by Alexander [ 14/Aug/12 ]

I guess it is 'false' that is being returned? That's because MySql's tinyint will be mapped as boolean (by doctrine dbal).

Comment by Jonathan Robinson [ 28/Aug/12 ]

No. The value "" is returned as in an empty string.

Comment by Benjamin Eberlei [ 29/Aug/12 ]

can you show your mapping for this value?

Comment by Jonathan Robinson [ 09/Oct/12 ]

Sure. Mapping is:

/**

  • @var boolean $isvegetarian
    *
  • @Column(name="IsVegetarian", type="boolean", nullable=true)
    */
    private $isvegetarian;

DBAL maps field as a tiny int. If I manually set field to 0, DBAL returns null. If I set to null, DBAL returns null. If I set to 1, DBAL returns true.

Comment by Jonathan Robinson [ 10/Oct/12 ]

I installed the new version, then reverted back and the problem seems to have gone away. I'm very confused!! Perhaps it was an installation problem at my end. But can't think what. Oh well...

Comment by Jonathan Robinson [ 10/Oct/12 ]

nope, i'm wrong. it is a bug - something else fooled me into thinking it was working. I have tried setting up other boolean data fields and the same issue occurs.

Generated at Fri Oct 24 14:48:38 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.