alias function partly broken in peewee 3.9.4 and 3.9.5
See original GitHub issueI just upgraded from peewee 3.9.3 to 3.9.5 and suddenly I am getting the following error:
User, pw.JOIN.LEFT_OUTER, on=(User.id == recipemodel.Recipe.created_by).alias("a")
File "/home/anne/projects/recapi/venv/lib/python3.7/site-packages/peewee.py", line 698, in inner
method(clone, *args, **kwargs)
File "/home/anne/projects/recapi/venv/lib/python3.7/site-packages/peewee.py", line 6603, in join
on, attr, constructor = self._normalize_join(src, dest, on, attr)
File "/home/anne/projects/recapi/venv/lib/python3.7/site-packages/peewee.py", line 6534, in _normalize_join
attr == fk_field.object_id_name and not is_backref:
AttributeError: 'AutoField' object has no attribute 'object_id_name'
The same error occurs in peewee 3.9.4 but everything is running fine in 3.9.3. The code piece that breaks looks like this:
recipes = recipemodel.Recipe.select(
recipemodel.Recipe, User, Changed, pw.fn.group_concat(tagmodel.Tag.tagname).alias("taglist")
).where(
recipemodel.Recipe.published == published
).join(
User, pw.JOIN.LEFT_OUTER, on=(User.id == recipemodel.Recipe.created_by).alias("a")
).switch(
recipemodel.Recipe
).join(
Changed, pw.JOIN.LEFT_OUTER, on=(Changed.id == recipemodel.Recipe.changed_by).alias("b")
).switch(
recipemodel.Recipe
).join(
tagmodel.RecipeTags, pw.JOIN.LEFT_OUTER, on=(tagmodel.RecipeTags.recipeID == recipemodel.Recipe.id)
).join(
tagmodel.Tag, pw.JOIN.LEFT_OUTER, on=(tagmodel.Tag.id == tagmodel.RecipeTags.tagID)
).group_by(recipemodel.Recipe.id)
It’s the .alias("a")
and .alias("b")
bits that seem to be causing the trouble.
Please let me know if there is any relevant information lacking from this bug report.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
'Expression' object has no attribute 'name' · Issue #1914 ...
When joining two models on an expression, I started getting an error on 3.9.4 and 3.9.5. My models: import peewee db = peewee....
Read more >API Documentation — peewee 3.15.4 documentation
alias (str) – Alias to use for table in SQL queries. Note. If columns are specified, the magic “c” attribute will be disabled....
Read more >https://raw.githubusercontent.com/coleifer/peewee/...
Properly delegate to a foreign-key field's `db_value()` function when ... [View commits](https://github.com/coleifer/peewee/compare/3.9.4...3.9.5) ## 3.9.4 ...
Read more >Policy Manual - Henagar Junior High School
Employee Compensation. 3.9.1 Salaries and Pay Rates. 3.9.2 Payroll Procedures. 3.9.3 Local Supplements. 3.9.4 Salary Administration. 3.9.5 Salary Deductions.
Read more >Python Guide Documentation
Which functions should go into which modules? How does data flow through the project? What features and functions.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh, guess not, done.
Fixed, pushing a new release 3.9.6