summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorJason Kirtland <jek@discorporate.us>2007-10-23 07:38:07 +0000
committerJason Kirtland <jek@discorporate.us>2007-10-23 07:38:07 +0000
commit6378c347994c902f7d4e65e54f2b76d01ce603d2 (patch)
tree1953746106c9fce1f53c16d2638923db5e7f9e7f /test/sql
parent21c6fa79b1e5b19c444c9cdc125d67825759330d (diff)
downloadsqlalchemy-6378c347994c902f7d4e65e54f2b76d01ce603d2.tar.gz
- Added initial version of MaxDB dialect.
- All optional test Sequences are now optional=True
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/case_statement.py1
-rw-r--r--test/sql/query.py28
-rw-r--r--test/sql/rowcount.py3
-rw-r--r--test/sql/testtypes.py26
-rw-r--r--test/sql/unicode.py10
5 files changed, 43 insertions, 25 deletions
diff --git a/test/sql/case_statement.py b/test/sql/case_statement.py
index 493545b22..7856d758b 100644
--- a/test/sql/case_statement.py
+++ b/test/sql/case_statement.py
@@ -25,6 +25,7 @@ class CaseTest(PersistTest):
def tearDownAll(self):
info_table.drop()
+ @testing.unsupported('maxdb')
def testcase(self):
inner = select([case([
[info_table.c.pk < 3,
diff --git a/test/sql/query.py b/test/sql/query.py
index ba29d6a8f..67384073c 100644
--- a/test/sql/query.py
+++ b/test/sql/query.py
@@ -221,7 +221,7 @@ class QueryTest(PersistTest):
users.delete(users.c.user_name == 'fred').execute()
print repr(users.select().execute().fetchall())
-
+
def testselectlimit(self):
users.insert().execute(user_id=1, user_name='john')
users.insert().execute(user_id=2, user_name='jack')
@@ -233,7 +233,7 @@ class QueryTest(PersistTest):
r = users.select(limit=3, order_by=[users.c.user_id]).execute().fetchall()
self.assert_(r == [(1, 'john'), (2, 'jack'), (3, 'ed')], repr(r))
- @testing.unsupported('mssql')
+ @testing.unsupported('mssql', 'maxdb')
def testselectlimitoffset(self):
users.insert().execute(user_id=1, user_name='john')
users.insert().execute(user_id=2, user_name='jack')
@@ -247,8 +247,8 @@ class QueryTest(PersistTest):
r = users.select(offset=5, order_by=[users.c.user_id]).execute().fetchall()
self.assert_(r==[(6, 'ralph'), (7, 'fido')])
- @testing.supported('mssql')
- def testselectlimitoffset_mssql(self):
+ @testing.supported('mssql', 'maxdb')
+ def test_select_limit_nooffset(self):
try:
r = users.select(limit=3, offset=2, order_by=[users.c.user_id]).execute().fetchall()
assert False # InvalidRequestError should have been raised
@@ -423,8 +423,12 @@ class QueryTest(PersistTest):
assert (x == y == z) is True
def test_update_functions(self):
- """test sending functions and SQL expressions to the VALUES and SET clauses of INSERT/UPDATE instances,
- and that column-level defaults get overridden"""
+ """
+ Tests sending functions and SQL expressions to the VALUES and SET
+ clauses of INSERT/UPDATE instances, and that column-level defaults
+ get overridden.
+ """
+
meta = MetaData(testbase.db)
t = Table('t1', meta,
Column('id', Integer, Sequence('t1idseq', optional=True), primary_key=True),
@@ -444,7 +448,6 @@ class QueryTest(PersistTest):
r = t.insert(values=dict(value=func.length("sfsaafsda"))).execute()
id = r.last_inserted_ids()[0]
-
assert t.select(t.c.id==id).execute().fetchone()['value'] == 9
t.update(values={t.c.value:func.length("asdf")}).execute()
assert t.select().execute().fetchone()['value'] == 4
@@ -453,7 +456,8 @@ class QueryTest(PersistTest):
t2.insert(values=dict(value=func.length("one"))).execute()
t2.insert(values=dict(value=func.length("asfda") + -19)).execute(stuff="hi")
- assert select([t2.c.value, t2.c.stuff]).execute().fetchall() == [(7,None), (3,None), (-14,"hi")]
+ res = exec_sorted(select([t2.c.value, t2.c.stuff]))
+ self.assertEquals(res, [(-14, 'hi'), (3, None), (7, None)])
t2.update(values=dict(value=func.length("asdsafasd"))).execute(stuff="some stuff")
assert select([t2.c.value, t2.c.stuff]).execute().fetchall() == [(9,"some stuff"), (9,"some stuff"), (9,"some stuff")]
@@ -506,7 +510,7 @@ class QueryTest(PersistTest):
self.assertEqual([x.lower() for x in r.keys()], ['user_name', 'user_id'])
self.assertEqual(r.values(), ['foo', 1])
- @testing.unsupported('oracle', 'firebird')
+ @testing.unsupported('oracle', 'firebird', 'maxdb')
def test_column_accessor_shadow(self):
meta = MetaData(testbase.db)
shadowed = Table('test_shadowed', meta,
@@ -590,6 +594,7 @@ class QueryTest(PersistTest):
finally:
table.drop()
+ @testing.unsupported('maxdb')
def test_in_filtering(self):
"""test the behavior of the in_() function."""
@@ -717,6 +722,7 @@ class CompoundTest(PersistTest):
('ccc', 'aaa')]
self.assertEquals(u.execute().fetchall(), wanted)
+ @testing.unsupported('maxdb')
def test_union_ordered_alias(self):
(s1, s2) = (
select([t1.c.col3.label('col3'), t1.c.col4.label('col4')],
@@ -1125,9 +1131,11 @@ class OperatorTest(PersistTest):
def tearDownAll(self):
metadata.drop_all()
+ @testing.unsupported('maxdb')
def test_modulo(self):
self.assertEquals(
- select([flds.c.intcol % 3], order_by=flds.c.idcol).execute().fetchall(),
+ select([flds.c.intcol % 3],
+ order_by=flds.c.idcol).execute().fetchall(),
[(2,),(1,)]
)
diff --git a/test/sql/rowcount.py b/test/sql/rowcount.py
index 095f79200..4bd52b9fa 100644
--- a/test/sql/rowcount.py
+++ b/test/sql/rowcount.py
@@ -47,6 +47,7 @@ class FoundRowsTest(AssertMixin):
# WHERE matches 3, 3 rows changed
department = employees_table.c.department
r = employees_table.update(department=='C').execute(department='Z')
+ print "expecting 3, dialect reports %s" % r.rowcount
if testbase.db.dialect.supports_sane_rowcount:
assert r.rowcount == 3
@@ -54,6 +55,7 @@ class FoundRowsTest(AssertMixin):
# WHERE matches 3, 0 rows changed
department = employees_table.c.department
r = employees_table.update(department=='C').execute(department='C')
+ print "expecting 3, dialect reports %s" % r.rowcount
if testbase.db.dialect.supports_sane_rowcount:
assert r.rowcount == 3
@@ -61,6 +63,7 @@ class FoundRowsTest(AssertMixin):
# WHERE matches 3, 3 rows deleted
department = employees_table.c.department
r = employees_table.delete(department=='C').execute()
+ print "expecting 3, dialect reports %s" % r.rowcount
if testbase.db.dialect.supports_sane_rowcount:
assert r.rowcount == 3
diff --git a/test/sql/testtypes.py b/test/sql/testtypes.py
index 71313ec42..101efb79b 100644
--- a/test/sql/testtypes.py
+++ b/test/sql/testtypes.py
@@ -41,13 +41,14 @@ class MyUnicodeType(types.TypeDecorator):
impl = Unicode
def bind_processor(self, dialect):
- impl_processor = super(MyUnicodeType, self).bind_processor(dialect)
+ impl_processor = super(MyUnicodeType, self).bind_processor(dialect) or (lambda value:value)
+
def process(value):
return "UNI_BIND_IN"+ impl_processor(value)
return process
def result_processor(self, dialect):
- impl_processor = super(MyUnicodeType, self).result_processor(dialect)
+ impl_processor = super(MyUnicodeType, self).result_processor(dialect) or (lambda value:value)
def process(value):
return impl_processor(value) + "UNI_BIND_OUT"
return process
@@ -264,9 +265,10 @@ class UnicodeTest(AssertMixin):
unicode_text=unicodedata,
plain_varchar=rawdata)
x = unicode_table.select().execute().fetchone()
- print repr(x['unicode_varchar'])
- print repr(x['unicode_text'])
- print repr(x['plain_varchar'])
+ print 0, repr(unicodedata)
+ print 1, repr(x['unicode_varchar'])
+ print 2, repr(x['unicode_text'])
+ print 3, repr(x['plain_varchar'])
self.assert_(isinstance(x['unicode_varchar'], unicode) and x['unicode_varchar'] == unicodedata)
self.assert_(isinstance(x['unicode_text'], unicode) and x['unicode_text'] == unicodedata)
if isinstance(x['plain_varchar'], unicode):
@@ -293,9 +295,10 @@ class UnicodeTest(AssertMixin):
unicode_text=unicodedata,
plain_varchar=rawdata)
x = unicode_table.select().execute().fetchone()
- print repr(x['unicode_varchar'])
- print repr(x['unicode_text'])
- print repr(x['plain_varchar'])
+ print 0, repr(unicodedata)
+ print 1, repr(x['unicode_varchar'])
+ print 2, repr(x['unicode_text'])
+ print 3, repr(x['plain_varchar'])
self.assert_(isinstance(x['unicode_varchar'], unicode) and x['unicode_varchar'] == unicodedata)
self.assert_(isinstance(x['unicode_text'], unicode) and x['unicode_text'] == unicodedata)
self.assert_(isinstance(x['plain_varchar'], unicode) and x['plain_varchar'] == unicodedata)
@@ -363,7 +366,7 @@ class DateTest(AssertMixin):
global users_with_date, insert_data
db = testbase.db
- if db.engine.name == 'oracle':
+ if testing.against('oracle'):
import sqlalchemy.databases.oracle as oracle
insert_data = [
[7, 'jack',
@@ -393,8 +396,11 @@ class DateTest(AssertMixin):
time_micro = 999
# Missing or poor microsecond support:
- if db.engine.name in ('mssql', 'mysql', 'firebird'):
+ if testing.against('mssql', 'mysql', 'firebird'):
datetime_micro, time_micro = 0, 0
+ # No microseconds for TIME
+ elif testing.against('maxdb'):
+ time_micro = 0
insert_data = [
[7, 'jack',
diff --git a/test/sql/unicode.py b/test/sql/unicode.py
index 55f3f6bc5..03673eb4d 100644
--- a/test/sql/unicode.py
+++ b/test/sql/unicode.py
@@ -8,7 +8,7 @@ from testlib.engines import utf8_engine
class UnicodeSchemaTest(PersistTest):
- @testing.unsupported('oracle', 'sybase')
+ @testing.unsupported('maxdb', 'oracle', 'sybase')
def setUpAll(self):
global unicode_bind, metadata, t1, t2, t3
@@ -55,20 +55,20 @@ class UnicodeSchemaTest(PersistTest):
)
metadata.create_all()
- @testing.unsupported('oracle', 'sybase')
+ @testing.unsupported('maxdb', 'oracle', 'sybase')
def tearDown(self):
if metadata.tables:
t3.delete().execute()
t2.delete().execute()
t1.delete().execute()
- @testing.unsupported('oracle', 'sybase')
+ @testing.unsupported('maxdb', 'oracle', 'sybase')
def tearDownAll(self):
global unicode_bind
metadata.drop_all()
del unicode_bind
- @testing.unsupported('oracle', 'sybase')
+ @testing.unsupported('maxdb', 'oracle', 'sybase')
def test_insert(self):
t1.insert().execute({u'méil':1, u'\u6e2c\u8a66':5})
t2.insert().execute({'a':1, 'b':1})
@@ -81,7 +81,7 @@ class UnicodeSchemaTest(PersistTest):
assert t2.select().execute().fetchall() == [(1, 1)]
assert t3.select().execute().fetchall() == [(1, 5, 1, 1)]
- @testing.unsupported('oracle', 'sybase')
+ @testing.unsupported('maxdb', 'oracle', 'sybase')
def test_reflect(self):
t1.insert().execute({u'méil':2, u'\u6e2c\u8a66':7})
t2.insert().execute({'a':2, 'b':2})