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

Update method 'column' variable overwritten #157

Closed
theos15 opened this issue Sep 6, 2024 · 3 comments · Fixed by #162
Closed

Update method 'column' variable overwritten #157

theos15 opened this issue Sep 6, 2024 · 3 comments · Fixed by #162

Comments

@theos15
Copy link

theos15 commented Sep 6, 2024

Describe the bug or question
In certain environments the line in the update method:
model_columns = {column.name for column in inspect(self.model).c} writes over the column import for the below line:
stmt = stmt.returning(*[column(name) for name in return_columns])

Description
column import being overwritten by local loop, resulting in the following error:

UnboundLocalError: cannot access local variable 'column' where it is not associated with a value

Updating the line with a new variable name fixes the issue:
model_columns = {_column.name for _column in inspect(self.model).c}
Screenshots
image```python

@renja-g
Copy link

renja-g commented Sep 8, 2024

I also just got this error:

updated_post = await crud_profile.update(db=db, object=values, schema_to_select=ProfileRead, return_as_model=True, id=id)
fastcrud/crud/fast_crud.py", line 1980, in update
    stmt = stmt.returning(*[column(name) for name in return_columns])
                            ^^^^^^
UnboundLocalError: cannot access local variable 'column' where it is not associated with a value

@igorbenav
Copy link
Owner

I'll upload a fix. Do you want to do it, @theos15?

@renja-g
Copy link

renja-g commented Sep 8, 2024

I'll upload a fix. Do you want to do it, @theos15?

I would appreciate that

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

Successfully merging a pull request may close this issue.

3 participants