Merge lp:~jtv/storm/bug-659078 into lp:storm

Proposed by Jeroen T. Vermeulen
Status: Merged
Merged at revision: 376
Proposed branch: lp:~jtv/storm/bug-659078
Merge into: lp:storm
Diff against target: 65 lines (+7/-8)
2 files modified
storm/sqlobject.py (+3/-3)
tests/sqlobject.py (+4/-5)
To merge this branch: bzr merge lp:~jtv/storm/bug-659078
Reviewer Review Type Date Requested Status
Björn Tillenius (community) Approve
Jamu Kakar (community) Approve
Storm Developers code Pending
Review via email: mp+38208@code.launchpad.net

Commit message

SQLObject "is_empty" was inverted.

Description of the change

See bug 659078. It was Brad who did the work on this one; I just put it into code to help the fix along.

To post a comment you must log in.
Revision history for this message
Jamu Kakar (jkakar) wrote :

Looks good to me, +1!

review: Approve
Revision history for this message
Björn Tillenius (bjornt) wrote :

+1!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'storm/sqlobject.py'
2--- storm/sqlobject.py 2010-08-05 19:43:41 +0000
3+++ storm/sqlobject.py 2010-10-12 12:06:44 +0000
4@@ -1,5 +1,5 @@
5 #
6-# Copyright (c) 2006, 2007 Canonical
7+# Copyright (c) 2006-2010 Canonical
8 #
9 # Written by Gustavo Niemeyer <gustavo@niemeyer.net>
10 #
11@@ -558,12 +558,12 @@
12 new code, prefer L{is_empty}. It's compatible with L{ResultSet}
13 which doesn't have a C{__nonzero__} implementation.
14 """
15- return self.is_empty()
16+ return not self.is_empty()
17
18 def is_empty(self):
19 """Return C{True} if this result set doesn't contain any results."""
20 result_set = self._without_prejoins()._result_set
21- return not result_set.is_empty()
22+ return result_set.is_empty()
23
24 def count(self):
25 result_set = self._without_prejoins()._result_set
26
27=== modified file 'tests/sqlobject.py'
28--- tests/sqlobject.py 2010-08-02 17:52:46 +0000
29+++ tests/sqlobject.py 2010-10-12 12:06:44 +0000
30@@ -1,5 +1,5 @@
31 #
32-# Copyright (c) 2006, 2007 Canonical
33+# Copyright (c) 2006-2010 Canonical
34 #
35 # Written by Gustavo Niemeyer <gustavo@niemeyer.net>
36 #
37@@ -25,7 +25,6 @@
38 from storm.exceptions import NoneError
39 from storm.sqlobject import *
40 from storm.store import Store
41-from storm.expr import Asc, Like
42 from storm.tz import tzutc
43
44 from tests.helper import TestHelper
45@@ -785,7 +784,7 @@
46 def test_result_set__nonzero__(self):
47 """
48 L{SQLObjectResultSet.__nonzero__} returns C{True} if the result set
49- doesn't contain any results. If it does contain results, C{False} is
50+ contains results. If it contains no results, C{False} is
51 returned.
52 """
53 result = self.Person.select()
54@@ -800,9 +799,9 @@
55 returned.
56 """
57 result = self.Person.select()
58+ self.assertEquals(result.is_empty(), False)
59+ result = self.Person.select(self.Person.q.name == "No Person")
60 self.assertEquals(result.is_empty(), True)
61- result = self.Person.select(self.Person.q.name == "No Person")
62- self.assertEquals(result.is_empty(), False)
63
64 def test_result_set_distinct(self):
65 result = self.Person.select("person.name = 'John Joe'",

Subscribers

People subscribed via source and target branches

to status/vote changes: