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

Unknown column 'Tagged.fk_table' in 'on clause' #28

Open
bmeclazcke opened this issue Dec 15, 2015 · 2 comments
Open

Unknown column 'Tagged.fk_table' in 'on clause' #28

bmeclazcke opened this issue Dec 15, 2015 · 2 comments

Comments

@bmeclazcke
Copy link

I'm trying to accomplish a search on several fields, including tags.

When trying to use matching or innerJoinWith Tags, I'm getting that error. Following on the query that is generated by CakePHP, I get the following (fragment of query)

...
INNER JOIN tags_tags Tags ON Tagged.fk_table = 'projects'
INNER JOIN tags_tagged Tagged ON (Projects.id = (Tagged.fk_id) AND Tags.id = (Tagged.tag_id))
...

Resulting in a crash error:
Unknown column 'Tagged.fk_table' in 'on clause'

Thanks!

@Phillaf
Copy link

Phillaf commented Dec 16, 2015

What does your behavior configuration look like?

@bmeclazcke
Copy link
Author

Same as default one, haven't changed it. After following the instructions and include the behavior in the models, tag saving is working great, just found this bug when using Tags with matching and innerJoinWith like this:

    $projects
                ->where(['LOWER(Projects.name) LIKE' => '%'.$search.'%'])
                ->orWhere(['LOWER(Projects.objectives) LIKE' => '%'.$search.'%'])
                ->orWhere(['LOWER(Users.full_name) LIKE' => '%'.$search.'%'])
                ->orWhere(['LOWER(Tags.label) LIKE' => '%'.$search.'%'])
                ->orWhere(['LOWER(Products.name) LIKE' => '%'.$search.'%'])
                ->matching(['Tags'])
                ->group(['Projects.id']);

If I include the like sentence in the matching/innerJoinWith query as a closure is the same result, trying to extract it as a custom finder. I've given a good 4hs going around and the only solution I found is to customize behavior configuration just for that query. But I was wondering if there's some other workaround that would avoid doing that (because I personally think that's a pretty ugly solution)

Thanks!

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

No branches or pull requests

2 participants