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

SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type boolean: "" 500 Internal Server Error - PDOException 

This error message causes Doctrine2 (2.2-DEV), and I am afraid that this error has appeared again: http://www.doctrine-project.org/jira/browse/DDC-1394

The query causing this error is as follows:

 public function getFindAllNonOthersQueryBuilder() { return $this ->createQueryBuilder('t') ->where('t.isOther = :isOther') ->setParameter('isOther', false); } 

The isOther field is displayed as follows:

 /** * @var boolean $isOther * * @ORM\Column(name="isOther", type="boolean") */ protected $isOther = false; 

What's going on here? I checked the type in the postgres database as well as boolean

+4
source share
3 answers

You must use the Literal expression. This is due to issue # DDC-1683

My sample code is:

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

I did a few more searches, since I have the same problem, and I found a solution through FOSMessageBundle if adding '\ PDO :: PARAM_BOOL' to your setParameter works like this:

 $qb->setParameter('isOther', false, \PDO::PARAM_BOOL); 
+6
source

I had the same problem.

Solution: Use 0 instead of false :

 ... ->setParameter('isOther', 0); 
0
source

All Articles