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

Table name not aliased properly in WHERE subselect #36

Closed
taylorhughes opened this issue Mar 18, 2014 · 2 comments
Closed

Table name not aliased properly in WHERE subselect #36

taylorhughes opened this issue Mar 18, 2014 · 2 comments

Comments

@taylorhughes
Copy link

I have a test case: taylorhughes@0ed47fc

That causes the following error:

LOG:  statement: SELECT "tests_compositebitfieldtestmodel"."id", "tests_compositebitfieldtestmodel"."flags_1", "tests_compositebitfieldtestmodel"."flags_2" FROM "tests_compositebitfieldtestmodel" WHERE "tests_compositebitfieldtestmodel"."id" IN (SELECT U0."id" FROM "tests_bitfieldtestmodel" U0 WHERE NOT (U0."another_name" =  ("tests_bitfieldtestmodel"."another_name" | 2)))
ERROR:  invalid reference to FROM-clause entry for table "tests_bitfieldtestmodel" at character 312

The issue is that the WHERE condition should be updated with a new aliased table name, "U0" in this case. This has something to do with the django field method relabel_aliases(), I think, but I can't track it down exactly.

If someone can explain how to fix it I'm happy to build and test a fix, but I'm not too familiar with the depths of django here. :)

@taylorhughes
Copy link
Author

Also I should say I attempted to handle a relabel_aliases() in BitQueryLookupWrapper, but at the point where I could trace things through, it seemed like the filter value was still a Bit. Adding the alias map handling into the Bit itself seemed dirty, so, not sure where things should go...

@taylorhughes
Copy link
Author

Duplicate of #31

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

1 participant