Hi there! I have a very complicated queries generator and I want to test it. Currently it looks like that:
def test(): query = generate_query() compiled = compile_query(query) assert compiled == 'SELECT * FROM table' Problems begin when I add some filters to query: def test(): query = generate_query_with_filters() compiled = compile_query(query) assert compiled == 'SELECT * FROM table WHERE a = 1 and b = 2' This test can fail sometimes because condition in compiled query can be swaped: "SELECT * FROM table WHERE b = 2 and a = 1". Is there any way to compare Query objects? I tried to do this (does't work): a = Model.query b = Model.query # assert a == b, 'failed' a = Model.query.filter(Model.col == 1) b = Model.query.filter(Model.col == 1) # assert a.statement == b.statement -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.