summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorPhilip Jenvey <pjenvey@underboss.org>2009-09-24 02:11:56 +0000
committerPhilip Jenvey <pjenvey@underboss.org>2009-09-24 02:11:56 +0000
commit5a9c1b8824bb84aaf8baccdfa2780a94af5c0f44 (patch)
treeabb0eed7f59567b73b0087d2f1e68c89254f7d2a /test/sql
parent79ce8e89bd0537d26c8c3594557b2aa4c67f8f90 (diff)
downloadsqlalchemy-5a9c1b8824bb84aaf8baccdfa2780a94af5c0f44.tar.gz
merge from branches/clauseelement-nonzero
adds a __nonzero__ to _BinaryExpression to avoid faulty comparisons during hash collisions (which only occur on Jython) fixes #1547
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/test_defaults.py5
-rw-r--r--test/sql/test_generative.py4
-rw-r--r--test/sql/test_select.py7
-rw-r--r--test/sql/test_selectable.py16
4 files changed, 19 insertions, 13 deletions
diff --git a/test/sql/test_defaults.py b/test/sql/test_defaults.py
index 5638dad77..95e87ecbf 100644
--- a/test/sql/test_defaults.py
+++ b/test/sql/test_defaults.py
@@ -552,10 +552,11 @@ class SequenceTest(testing.TestBase):
engine = engines.testing_engine(options={'implicit_returning':False})
result = engine.execute(sometable.insert(), name="somename")
- assert 'id' in result.postfetch_cols()
+
+ assert set(result.postfetch_cols()) == set([sometable.c.obj_id])
result = engine.execute(sometable.insert(), name="someother")
- assert 'id' in result.postfetch_cols()
+ assert set(result.postfetch_cols()) == set([sometable.c.obj_id])
sometable.insert().execute(
{'name':'name3'},
diff --git a/test/sql/test_generative.py b/test/sql/test_generative.py
index 7c094c26b..0bff777b8 100644
--- a/test/sql/test_generative.py
+++ b/test/sql/test_generative.py
@@ -5,7 +5,7 @@ from sqlalchemy.test import *
from sqlalchemy.sql.visitors import *
from sqlalchemy import util
from sqlalchemy.sql import util as sql_util
-
+from sqlalchemy.test.testing import eq_
class TraversalTest(TestBase, AssertsExecutionResults):
"""test ClauseVisitor's traversal, particularly its ability to copy and modify
@@ -178,7 +178,7 @@ class ClauseTest(TestBase, AssertsCompiledSQL):
def test_binary(self):
clause = t1.c.col2 == t2.c.col2
- assert str(clause) == CloningVisitor().traverse(clause)
+ eq_(str(clause), str(CloningVisitor().traverse(clause)))
def test_binary_anon_label_quirk(self):
t = table('t1', column('col1'))
diff --git a/test/sql/test_select.py b/test/sql/test_select.py
index 9acc94eb2..8e30acf41 100644
--- a/test/sql/test_select.py
+++ b/test/sql/test_select.py
@@ -1374,7 +1374,12 @@ UNION SELECT mytable.myid FROM mytable WHERE mytable.myid = :myid_2)")
(t1.c.col1, 'col1', 'mytable.col1', None),
(column('some wacky thing'), 'some wacky thing', '"some wacky thing"', '')
):
- s1 = select([col], from_obj=getattr(col, 'table', None) or table1)
+ if getattr(col, 'table', None) is not None:
+ t = col.table
+ else:
+ t = table1
+
+ s1 = select([col], from_obj=t)
assert s1.c.keys() == [key], s1.c.keys()
if label:
diff --git a/test/sql/test_selectable.py b/test/sql/test_selectable.py
index 95ca0d17b..147e47cd9 100644
--- a/test/sql/test_selectable.py
+++ b/test/sql/test_selectable.py
@@ -119,9 +119,9 @@ class SelectableTest(TestBase, AssertsExecutionResults):
u = union(select([table1.c.col1, table1.c.col2, table1.c.col3]), select([table1.c.col1, table1.c.col2, table1.c.col3]))
u = union(select([table1.c.col1, table1.c.col2, table1.c.col3]))
- assert u.c.col1
- assert u.c.col2
- assert u.c.col3
+ assert u.c.col1 is not None
+ assert u.c.col2 is not None
+ assert u.c.col3 is not None
def test_alias_union(self):
# same as testunion, except its an alias of the union
@@ -188,10 +188,10 @@ class SelectableTest(TestBase, AssertsExecutionResults):
l1 = select([func.max(table1.c.col1)]).label('foo')
s = select([l1])
- assert s.corresponding_column(l1).name == s.c.foo
+ eq_(s.corresponding_column(l1), s.c.foo)
s = select([table1.c.col1, l1])
- assert s.corresponding_column(l1).name == s.c.foo
+ eq_(s.corresponding_column(l1), s.c.foo)
def test_select_alias_labels(self):
a = table2.select(use_labels=True).alias('a')
@@ -262,12 +262,12 @@ class PrimaryKeyTest(TestBase, AssertsExecutionResults):
d = Table('d', meta, Column('id', Integer, ForeignKey('c.id'), primary_key=True), Column('x', Integer))
print list(a.join(b, a.c.x==b.c.id).primary_key)
- assert list(a.join(b, a.c.x==b.c.id).primary_key) == [b.c.id]
+ assert list(a.join(b, a.c.x==b.c.id).primary_key) == [a.c.id]
assert list(b.join(c, b.c.x==c.c.id).primary_key) == [b.c.id]
assert list(a.join(b).join(c, c.c.id==b.c.x).primary_key) == [a.c.id]
- assert list(b.join(c, c.c.x==b.c.id).join(d).primary_key) == [c.c.id]
+ assert list(b.join(c, c.c.x==b.c.id).join(d).primary_key) == [b.c.id]
assert list(b.join(c, c.c.id==b.c.x).join(d).primary_key) == [b.c.id]
- assert list(d.join(b, d.c.id==b.c.id).join(c, b.c.id==c.c.x).primary_key) == [c.c.id]
+ assert list(d.join(b, d.c.id==b.c.id).join(c, b.c.id==c.c.x).primary_key) == [b.c.id]
assert list(a.join(b).join(c, c.c.id==b.c.x).join(d).primary_key) == [a.c.id]
assert list(a.join(b, and_(a.c.id==b.c.id, a.c.x==b.c.id)).primary_key) == [a.c.id]