Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1967

mysql Tiny ints not behaving properley

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: 2.2.2
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All
    • 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.

        Activity

        Hide
        Jonathan Robinson added a comment -

        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.

        Show
        Jonathan Robinson added a comment - 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.
        Hide
        Jonathan Robinson added a comment -

        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...

        Show
        Jonathan Robinson added a comment - 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...
        Hide
        Jonathan Robinson added a comment -

        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.

        Show
        Jonathan Robinson added a comment - 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.
        Hide
        Benjamin Eberlei added a comment -

        can you show your mapping for this value?

        Show
        Benjamin Eberlei added a comment - can you show your mapping for this value?
        Hide
        Jonathan Robinson added a comment -

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

        Show
        Jonathan Robinson added a comment - No. The value "" is returned as in an empty string.
        Hide
        Alexander added a comment -

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

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

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Jonathan Robinson
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: