Discussed in #6693
Originally posted by ShmuelTreiger June 30, 2021
Now that session.query isn't recommended, is there a way to create a custom Select object? Similar to this stackoverflow question: https://stackoverflow.com/questions/15936111/sqlalchemy-can-you-add-custom-methods-to-the-query-object
I've looked around and haven't found anything, just thought I would see if I'm missing something before raising an issue.
So far I have been able to create the custom class and inherit from select, but I have been unable to add it to the session.
class CustomSelect(Select):
def custom_method(self):
pass
Session(select_cls=CustomSelect, future=True)
The class works, the session doesn't
As mentioned by Mike here: #6693 (reply in thread)
in 1.4 there is no public api and no documentation on how to subclass a select correctly.
cc @ShmuelTreiger
Discussed in #6693
Originally posted by ShmuelTreiger June 30, 2021
Now that session.query isn't recommended, is there a way to create a custom Select object? Similar to this stackoverflow question: https://stackoverflow.com/questions/15936111/sqlalchemy-can-you-add-custom-methods-to-the-query-object
I've looked around and haven't found anything, just thought I would see if I'm missing something before raising an issue.
So far I have been able to create the custom class and inherit from select, but I have been unable to add it to the session.
The class works, the session doesn't
As mentioned by Mike here: #6693 (reply in thread)
in 1.4 there is no public api and no documentation on how to subclass a select correctly.
cc @ShmuelTreiger