question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

alias function partly broken in peewee 3.9.4 and 3.9.5

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
coleifercommented, Jun 6, 2019

Oh, guess not, done.

1reaction
coleifercommented, Jun 3, 2019

Fixed, pushing a new release 3.9.6

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found