Doctrine2 and Postgres : Invalid input syntax for boolean : ""

doctrine-orm, php, postgresql, symfony

Solution

You have to use `Literal` expression. It is related with issue #DDC-1683

My sample code:

$q->andWhere($q->expr()->eq('item.published', $q->expr()->literal(true)));

Problem

``` SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type boolean: "" 500 Internal Server Error - PDOException ``` It's the error message cause by Doctrine2 (2.2-DEV) and i'm afraid it's that bug which appeared again: http://www.doctrine-project.org/jira/browse/DDC-1394 The query which causes this error is as follows: ``` public function getFindAllNonOthersQueryBuilder() { return $this ->createQueryBuilder('t') ->where('t.isOther = :isOther') ->setParameter('isOther', false); } ``` The field isOther is mapped this way : ``` /** * @var boolean $isOther * * @ORM\Column(name="isOther", type="boolean") */ protected $isOther = false; ``` What's happening in here? I've checked the type in the postgres database and it's a `boolean` too

Original source