1

I'm learning symfony 2 currently. Before, I was using MySQL, but I wanted to try the power of Symfony 2 and doctrine. So I wanted to switch from MySQL to PostgreSQL. I have everything well installed... The database was created with the doctrine command, the dump was successful too... When I wanted to register a new user from the home page. I had this exception :

An exception occurred while executing 'SELECT t0.username AS username1,
t0.username_canonical AS username_canonical2, t0.email AS email3, t0.email_canonical AS
email_canonical4, t0.enabled AS enabled5, t0.salt AS salt6, t0.password AS password7,
t0.last_login AS last_login8, t0.locked AS locked9, t0.expired AS expired10, t0.expires_at
AS expires_at11, t0.confirmation_token AS confirmation_token12, t0.password_requested_at 
AS password_requested_at13, t0.roles AS roles14, t0.credentials_expired AS
credentials_expired15, t0.credentials_expire_at AS credentials_expire_at16, t0.id AS id17, 
t0.nb_postes AS nb_postes18, t0.nb_following AS nb_following19, t0.nb_followers AS 
nb_followers20 FROM User t0 WHERE t0.username_canonical = ?' with params ["okay"]:

SQLSTATE[42809]: Wrong object type: 7 ERROR: column notation .username applied to type 
name, which is not a composite type
LINE 1: SELECT t0.username AS username1, t0.username_canonical AS us...

My queries worked very well with MySQL, but with PostgreSQL, I got this :/ . I haven't found anything on the web about ERROR: column notation ... If one of you know how to resolve this please ... :)

1 Answer 1

1

You just need escaping:

/**
 * @Entity
 * @Table("`user`")
 */
class User {
}

Those backticks will make Doctrine use "user" instead of user in the queries.

Sign up to request clarification or add additional context in comments.

2 Comments

Exactly... Thanks for the tip dude !! But if I want User, with Uppercase for the first letter, I have to do exactly "`User`" .
Sure. I just prefer everything in lowercase in PostgreSQL because it's idiomatic. If my answer solved your problem, please don't forget to mark it as the right one.

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.