Details
Description
When selecting all objects of SecondClass and ThirdClass which both inherit from FirstClass with the following code :
$em->getRepository('FirstClass')->findAll();
Postgresql is throwing the following error :
Invalid text representation: 7 ERROR: invalid input syntax for integer: "" LINE 1: ...er_stuff3 FROM "first_class" t0 WHERE t0.type IN ('', '1', '...
I think it's because of the empty string after the IN clause.
There is the fail test case :
Classes :
class FirstClass {
private $id;
private $type;
}
class SecondClass extends FirstClass {
private $otherStuff;
}
class ThirdClass extends FirstClass {
private $otherStuff;
}
Mapping :
<?xml version="1.0" encoding="UTF-8"?> <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> <entity name="FirstClass" table='"first_class"' inheritance-type="SINGLE_TABLE"> <id name="id" type="integer" column="id"> <generator strategy="SEQUENCE"/> <sequence-generator sequence-name="first_class_id_seq" allocation-size="1" initial-value="1"/> </id> <discriminator-column name="type" type="integer" field-name="type" /> <discriminator-map> <discriminator-mapping value="1" class="ThirdClass" /> <discriminator-mapping value="2" class="SecondClass" /> </discriminator-map> </entity> </doctrine-mapping> <?xml version="1.0" encoding="UTF-8"?> <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> <entity name="SecondClass"> <field name="otherStuff" column="other_stuff" type="string" /> </entity> </doctrine-mapping> <?xml version="1.0" encoding="UTF-8"?> <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> <entity name="ThirdClass"> <field name="otherStuff" column="other_stuff" type="string" /> </entity> </doctrine-mapping>
The SQL :
CREATE TABLE first_class
(
id serial NOT NULL,
"type" integer,
other_stuff character varying,
CONSTRAINT first_class_pkey PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
The fail test :
require_once 'class/FirstClass.php';
require_once 'class/SecondClass.php';
require_once 'class/ThirdClass.php';
$entities = $doctrineEntityManager->getRepository('FirstClass')->findAll();
The problem seems to come from Doctrine\ORM\Persisters\SingleTablePersister::_getSelectConditionSQL()