Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

StateManager query interface may need to change #181

Open
jace opened this issue Mar 13, 2018 · 2 comments
Open

StateManager query interface may need to change #181

jace opened this issue Mar 13, 2018 · 2 comments

Comments

@jace
Copy link
Member

jace commented Mar 13, 2018

StateManager currently allows database queries like this:

Document.query.filter(Document.state.PUBLISHED).all()

Unfortunately, this makes it impossible to examine the PUBLISHED workflow state, as any attempt to access it will render a query. The rendering could shift to a function call:

Document.query.filter(Document.state.PUBLISHED()).all()

This is a breaking change unless SQLAlchemy provides us a way to cast an object into a SQL expression.

@jace
Copy link
Member Author

jace commented Mar 13, 2018

This change mirrors the changes introduced in #166 (specifically, 8979fa9, for #165), where instead of returning a boolean when accessed via the instance, we return an object that implements __bool__. Unfortunately, SQLAlchemy doesn't give us an equivalent __sql__, and inheriting from ClauseElement will have unknown side effects.

@jace
Copy link
Member Author

jace commented Mar 20, 2019

To be investigated: will it work to offer a __clause_element__ method? This appears to be what SQLAlchemy calls.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant