Skip to content

Loading…

DDC-1051: Generated SQL Query Missing Table/Join Constraint leading to SQL Syntax Error #1642

Closed
doctrinebot opened this Issue · 2 comments

2 participants

@doctrinebot

Jira issue originally created by user webb.roger:

SELECT u, uc, ur
FROM ARN\EntityBundle\Entity\Users u
INNER JOIN u.contact_info uc
INNER JOIN u.user_roles ur
WHERE u.username = :username

Generates the following SQL Query

SELECT u0.user_id AS user_id0, u0_.username AS username1, u0_.password AS password2, u0_.contact_info_id AS contact_info_id3, u0_.user_active AS user_active4, u0_.user_date AS user_date5, u0_.office_id AS office_id6, u0_.superuser AS superuser7, c1_.contact_info_id AS contact_info_id8, c1_.first_name AS first_name9, c1_.last_name AS last_name10, c1_.address AS address11, c1_.city_id AS city_id12, c1_.zip AS zip13, c1_.email AS email14, u2_.user_role_id AS user_role_id15, u2_.role AS role16, u0_.contact_info_id AS contact_info_id17, c1_.city_id AS city_id18 FROM users u0_ INNER JOIN contact_info c1_ ON u0_.contact_info_id = c1_.contact_info_id INNER JOIN WHERE u0_.userid = ?')

Notice the "INNER JOIN WHERE", this is the problem.

The mapping is as follows:

Users->user_roles

/****
 * @orm:OneToMany(targetEntity="UserRoles", mappedBy="user")
 */
protected $user_roles;

UserRoles->user

/****
 * @ManyToOne(targetEntity="Users", inversedBy="user_roles")
 * @JoinColumn(name="user*id", referencedColumnName="user*id")
 */
protected $user;

Let me know if you need any more information. Happy to help. Thanks.

@doctrinebot

Comment created by webb.roger:

Problem was due to a missing "orm:" prefix for symfony annotations. Thanks.

@doctrinebot

Issue was closed with resolution "Invalid"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.