Re: [SQLObject] [PATCH] Allow empty argument list to AND/OR
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Johan D. <jd...@as...> - 2007-01-29 17:11:37
|
Oleg Broytmann wrote: > On Tue, Jan 23, 2007 at 11:51:27AM -0200, Johan Dahlin wrote: >> Here is a patch I recently wrote that makes makes it easier to write code >> that constructs queries dynamically: >> >> queries = [] >> >> if some_condition: >> queries.append(...) > > I am going to add the following test: > > def test_empty_AND(): > assert str(AND()) == "None" > assert str(AND(True)) == "True" > assert str(AND(1, 2)) == str(SQLOp("AND", 1, 2)) == "((1) AND (2))" > > str() is needed because AND() returns an SQLExpression that overrides > comparison. The following > AND('x', 'y') == "foo bar" > is True! (-: Eeek, but justified I guess :-) > > Can you think of a better test? Not without adding lots of application specific data, I think that's fine. You might want to add 3 and 4 arguments too, to test how the parenthesis are going to be structured. |