Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: I18n translation fails join after TreeBehavior->recover() #6794

Closed
gijsjager opened this issue Jun 12, 2015 · 10 comments
Closed

Bug: I18n translation fails join after TreeBehavior->recover() #6794

gijsjager opened this issue Jun 12, 2015 · 10 comments
Assignees
Labels
Milestone

Comments

@gijsjager
Copy link

I use a I18n on my table.
But it throws a DB error after TreeBehavior->recover();
It says the following message: "Error: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in order clause is ambiguous"

See the screenshot for more details.

How can I fix this?

cakeversion: 3.0.6

image

@dereuromark
Copy link
Member

You need to always add the exact version you are using, e.g. 3.0.5 etc.

@gijsjager
Copy link
Author

I edited my post :-)

@dereuromark dereuromark added this to the 3.0.7 milestone Jun 12, 2015
@ADmad
Copy link
Member

ADmad commented Jun 12, 2015

@Bl00per Are you adding containments through a beforeFind() callback?

@gijsjager
Copy link
Author

@ADmad nope! This table only has a beforeSave callback and some containments in the init

@dereuromark
Copy link
Member

I think it is reasonable to always add the table for the order statement in order for the query to not be ambiguous.

@ADmad
Copy link
Member

ADmad commented Jun 12, 2015

I think it is reasonable to always add the table for the order statement in order for the query to not be ambiguous.

Yes it is but I want to understand how the joins got into the query. Ideally that query should be done without any joins since they are not needed.

@ADmad
Copy link
Member

ADmad commented Jun 12, 2015

and some containments in the init

@Bl00per "init" ?

@gijsjager
Copy link
Author

@ADmad aren't the joins generated by the I18n?
The table has a Translate Behavior

And I ment there are belongsTo + hasMany functions in the initialize() within the table class

@ADmad ADmad self-assigned this Jun 12, 2015
@ADmad
Copy link
Member

ADmad commented Jun 12, 2015

aren't the joins generated by the I18n?

Right, they are. I didn't ready the query carefully.

I'll fix the ambiguity though for efficiency I would suggest you to detach the behavior before running recover().

ADmad added a commit that referenced this issue Jun 12, 2015
@ADmad ADmad mentioned this issue Jun 12, 2015
@ADmad
Copy link
Member

ADmad commented Jun 12, 2015

Closing as PR is done.

@ADmad ADmad closed this as completed Jun 12, 2015
markstory added a commit that referenced this issue Jun 13, 2015
Both generated UnaryExpressions and OrderByExpression instances were
not being quoted correctly by the identifier quoter. The `foo IS NULL` and
`foo IS NOT NULL` expressions were missing identifier markers, while
order by statements were also missing identifier quoting. Correctly
quoting these query elements fixes errors in postgres related to
TreeBehavior.

Refs #6794
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants