Skip to content

Commit e56293b

Browse files
committed
Helpers for class Outer were changed to lookup columns in table's declarations
git-svn-id: http://svn.colorstudy.com/SQLObject/trunk@4613 95a46c32-92d2-0310-94a5-8d71aeb3d4b3
1 parent ba0f4d8 commit e56293b

3 files changed

Lines changed: 23 additions & 11 deletions

File tree

docs/News.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ News
1010
SQLObject (trunk)
1111
=================
1212

13+
Features & Interface
14+
--------------------
15+
16+
* Helpers for class Outer were changed to lookup columns in table's
17+
declarations.
18+
19+
Bugfixes
20+
--------
21+
1322
* A bug was fixed in DBConnection.close(); close() doesn't raise
1423
an UnboundLocalError if connection pool is empty.
1524

sqlobject/sqlbuilder.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,22 +1135,13 @@ def FULLOUTERJOINUsing(table1, table2, using_columns):
11351135
## Subqueries (subselects)
11361136
########################################
11371137

1138-
class OuterField(Field):
1138+
class OuterField(SQLObjectField):
11391139
def tablesUsedImmediate(self):
11401140
return []
11411141

1142-
class OuterTable(Table):
1142+
class OuterTable(SQLObjectTable):
11431143
FieldClass = OuterField
11441144

1145-
def __init__(self, table):
1146-
if hasattr(table, "sqlmeta"):
1147-
tableName = table.sqlmeta.table
1148-
else:
1149-
tableName = table
1150-
table = None
1151-
Table.__init__(self, tableName)
1152-
self.table = table
1153-
11541145
class Outer:
11551146
def __init__(self, table):
11561147
self.q = OuterTable(table)

sqlobject/tests/test_subqueries.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ class TestIn1(SQLObject):
1212
class TestIn2(SQLObject):
1313
col2 = StringCol()
1414

15+
class TestOuter(SQLObject):
16+
fk = ForeignKey('TestIn1')
17+
1518
def setup():
1619
setupClass(TestIn1)
1720
setupClass(TestIn2)
@@ -46,11 +49,20 @@ def test_3syntax_exists():
4649
assert str(select) == \
4750
"SELECT test_in1.id, test_in1.col1 FROM test_in1 WHERE NOT EXISTS (SELECT test_in2.col2 FROM test_in2 WHERE ((test_in1.col1) = (test_in2.col2)))"
4851

52+
setupClass(TestOuter)
53+
select = TestOuter.select(NOTEXISTS(Select(TestIn1.q.col1, where=(Outer(TestOuter).q.fk == TestIn1.q.id))))
54+
assert str(select) == \
55+
"SELECT test_outer.id, test_outer.fk_id FROM test_outer WHERE NOT EXISTS (SELECT test_in1.col1 FROM test_in1 WHERE ((test_outer.fk_id) = (test_in1.id)))"
56+
4957
def test_4perform_exists():
5058
insert()
5159
select = TestIn1.select(EXISTS(Select(TestIn2.q.col2, where=(Outer(TestIn1).q.col1 == TestIn2.q.col2))))
5260
assert len(list(select)) == 2
5361

62+
setupClass(TestOuter)
63+
select = TestOuter.select(NOTEXISTS(Select(TestIn1.q.col1, where=(Outer(TestOuter).q.fkID == TestIn1.q.id))))
64+
assert len(list(select)) == 0
65+
5466
def test_4syntax_direct():
5567
setup()
5668
select = TestIn1.select(TestIn1.q.col1 == Select(TestIn2.q.col2, where=(TestIn2.q.col2 == "test")))

0 commit comments

Comments
 (0)