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

frontend: Add backref relationship between Package and Build to silence sqlalchemy warnings #3032

Merged
merged 1 commit into from
Dec 4, 2023

Conversation

nikromen
Copy link
Member

Fixes #2445

@nikromen nikromen force-pushed the foreign-key-warning branch from c319ac6 to a11acf1 Compare November 27, 2023 14:37
@praiskup
Copy link
Member

Is the testsuite failing because of the change?

@FrostyX
Copy link
Member

FrostyX commented Nov 29, 2023

We already have this

class Package(db.Model, helpers.Serializer, CoprSearchRelatedData):
    ...
    builds = db.relationship("Build", order_by="Build.id")

which IMHO causes the collision

@nikromen nikromen force-pushed the foreign-key-warning branch from a11acf1 to ff8ae32 Compare November 29, 2023 17:27
@nikromen
Copy link
Member Author

which IMHO causes the collision

Yes, thank you. Unluckily... I cannot make alembic work locally on my machine to make migration. Could it somehow be because of the move to F39?

@FrostyX
Copy link
Member

FrostyX commented Nov 29, 2023

I cannot make alembic work locally on my machine to make migration.

What does it mean? A traceback, or ...?

@nikromen
Copy link
Member Author

When I run alembic revision --autogenerate -m "something" it just generates empty revision

... to silence sqlalchemy warnings

The Package.builds column is used only for read only purposes
and needs to be ordered accordingly against Build.id. Removing
viewonly=True parameter and making it read-write column will
result in errors since the relationship is used only for loading
objects and not for any persistence operation.

Setting the relationship to read-write would result in errors
since the relationship.sync_backref flag is set to True and
sqlalchemy tries then to sync the Package.builds column which
was never commited - thus "This session is in 'committed' state;
no further SQL can be emitted within this transaction." will appear.
@nikromen
Copy link
Member Author

nikromen commented Dec 3, 2023

Fixed that, pelase look to commit message for explanation

@nikromen nikromen force-pushed the foreign-key-warning branch from ff8ae32 to 876983a Compare December 3, 2023 21:17
Copy link
Member

@praiskup praiskup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you.

@praiskup praiskup merged commit 09117bf into fedora-copr:main Dec 4, 2023
7 checks passed
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 this pull request may close these issues.

copr-frontend alter-chroot warning
3 participants