6
    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

3 Answers 3

8

I did some more googling as I have the same issue and I found the solution through the FOSMessageBundle, if you add '\PDO::PARAM_BOOL' to your setParameter it works, like so:

$qb->setParameter('isOther', false, \PDO::PARAM_BOOL);
Sign up to request clarification or add additional context in comments.

Comments

5

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)));

Comments

2

I had the same problem.

Solution: Use 0 instead of false:

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

1 Comment

Yeah, 'false' seems to be ok too but i wanna know WHY ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.