Created
October 15, 2016 08:51
-
-
Save tsauerwein/09590bb1f4175dae44084427d6713999 to your computer and use it in GitHub Desktop.
SQLAlchemy: Using raw SQL in ORM statements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
participants_and_editor = text( | |
'ARRAY(SELECT DISTINCT UNNEST(array_cat(' | |
' ARRAY[guidebook.feed_document_changes.user_id], :participants)) ' | |
'ORDER BY 1)') | |
DBSession.execute( | |
DocumentChange.__table__.update(). | |
where(DocumentChange.document_id == outing_id). | |
where(DocumentChange.change_id != existing_change.change_id). | |
values(user_ids=participants_and_editor), | |
{'participants': participant_ids} | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment