Answer the question
In order to leave comments, you need to log in
How to tell the doctrine which namespace to use?
The error is simple - the doctrine makes a request:
SELECT t0.id AS id_1, t0.name AS name_2, t0.mentor_id AS mentor_id_3 FROM user t0
And gets an error:
[42703] ERROR: column t0.id does not exist
If you add the namespace public:
SELECT t0.id AS id_1, t0.name AS name_2, t0.mentor_id AS mentor_id_3 FROM public.user t0
Everything works fine.
Accordingly, the question is - where and how to specify the namespace for the doctrine?
doctrine.yaml
doctrine:
dbal:
driver: pdo_pgsql
url: '%env(resolve:DATABASE_URL)%'
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
DATABASE_URL=pgsql://myuser:[email protected]:5432/mydb
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\OneToOne;
/**
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
*/
class User
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @OneToOne(targetEntity="User")
* @JoinColumn(name="mentor_id", referencedColumnName="id", nullable=true)
*/
private $mentor;
//...
}
Answer the question
In order to leave comments, you need to log in
The word namespace is incorrect here.
Search by schema name and specifically search_path
It's strange that you don't know what search_path is, but you have it modified. The default setting includes the public schema, so both of your queries will usually do the same thing.
In the doctrine, starting from 2.5, the scheme is indicated as follows:
/**
* Clerk
*
* @Table(schema="schema")
*/
class Clerk { }
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question