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

Bare sqlalchemy metadata #2355

Merged
merged 2 commits into from
Mar 13, 2024
Merged

Conversation

benedikt-bartscher
Copy link
Contributor

@benedikt-bartscher benedikt-bartscher commented Jan 4, 2024

@benedikt-bartscher benedikt-bartscher marked this pull request as draft January 4, 2024 16:18
@benedikt-bartscher benedikt-bartscher force-pushed the bare-sqlalchemy branch 2 times, most recently from c4d9e9c to 85e2cf5 Compare March 7, 2024 20:33
@benedikt-bartscher benedikt-bartscher marked this pull request as ready for review March 7, 2024 20:34
reflex/model.py Outdated Show resolved Hide resolved
@benedikt-bartscher benedikt-bartscher force-pushed the bare-sqlalchemy branch 2 times, most recently from 38e58d1 to e47e534 Compare March 12, 2024 21:44
@benedikt-bartscher benedikt-bartscher marked this pull request as draft March 12, 2024 22:01
avoid chaining classmethod and property decorators
This is deprecated since python3.11 and won't
be supported in 3.13 and later
@benedikt-bartscher benedikt-bartscher marked this pull request as ready for review March 12, 2024 23:09
Copy link
Contributor

@picklelo picklelo left a comment

Choose a reason for hiding this comment

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

tested that existing functionality works. this will be a great extension to our model thanks for adding!

@picklelo picklelo merged commit 5701a72 into reflex-dev:main Mar 13, 2024
47 checks passed
Copy link
Collaborator

@masenf masenf left a comment

Choose a reason for hiding this comment

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

Discovered this potential issue to document while testing main

@@ -300,7 +382,6 @@ def migrate(cls, autogenerate: bool = False) -> bool | None:
return True

@classmethod
@property
Copy link
Collaborator

Choose a reason for hiding this comment

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

i think this might be a breaking change... my example app rx_shout was using select as a class property on a model.

And now it throws stack at runtime

Traceback (most recent call last):
  File "/Users/masenf/code/reflex-dev/reflex/reflex/state.py", line 1454, in _process_event
    events = fn(**payload)
             ^^^^^^^^^^^^^
  File "/Users/masenf/code/reflex-dev/repro-datetime-model/rx_shout/state.py", line 48, in on_load
    self.load_entries()
  File "/Users/masenf/code/reflex-dev/repro-datetime-model/rx_shout/state.py", line 45, in load_entries
    self.entries = session.exec(Entry.select.order_by(Entry.ts.desc())).all()
                                ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'function' object has no attribute 'order_by'

Workaround is to call the function instead of treating it like a property: Entry.select().order_by(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's a breaking change. However, I still think it was the right decision to drop those deprecated decorator chains.

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.

3 participants