diff options
| author | Paul Johnston <paj@pajhome.org.uk> | 2007-06-13 18:53:16 +0000 |
|---|---|---|
| committer | Paul Johnston <paj@pajhome.org.uk> | 2007-06-13 18:53:16 +0000 |
| commit | 2c65ce75360c6018ecc6160d6ef11e23ae628553 (patch) | |
| tree | 79908f4ba077776287975fee2fb694c22e49e450 /test/sql | |
| parent | e4cd7b2ed4303d2553692037ee74827e3f9dfa12 (diff) | |
| download | sqlalchemy-2c65ce75360c6018ecc6160d6ef11e23ae628553.tar.gz | |
Multiple MSSQL fixes; see ticket #581
Diffstat (limited to 'test/sql')
| -rw-r--r-- | test/sql/query.py | 13 | ||||
| -rw-r--r-- | test/sql/rowcount.py | 17 | ||||
| -rw-r--r-- | test/sql/testtypes.py | 23 |
3 files changed, 46 insertions, 7 deletions
diff --git a/test/sql/query.py b/test/sql/query.py index d788544c0..6e43f8779 100644 --- a/test/sql/query.py +++ b/test/sql/query.py @@ -402,6 +402,19 @@ class QueryTest(PersistTest): con.execute("""drop trigger paj""") meta.drop_all() + @testbase.supported('mssql') + def test_insertid_schema(self): + meta = BoundMetaData(testbase.db) + con = testbase.db.connect() + con.execute('create schema paj') + tbl = Table('test', meta, Column('id', Integer, primary_key=True), schema='paj') + tbl.create() + try: + tbl.insert().execute({'id':1}) + finally: + tbl.drop() + con.execute('drop schema paj') + class CompoundTest(PersistTest): """test compound statements like UNION, INTERSECT, particularly their ability to nest on diff --git a/test/sql/rowcount.py b/test/sql/rowcount.py index 05d0f2110..95cab898c 100644 --- a/test/sql/rowcount.py +++ b/test/sql/rowcount.py @@ -31,7 +31,7 @@ class FoundRowsTest(testbase.AssertMixin): i.execute(*[{'name':n, 'department':d} for n, d in data]) def tearDown(self): employees_table.delete().execute() - + def tearDownAll(self): employees_table.drop() @@ -45,23 +45,26 @@ class FoundRowsTest(testbase.AssertMixin): # WHERE matches 3, 3 rows changed department = employees_table.c.department r = employees_table.update(department=='C').execute(department='Z') - assert r.rowcount == 3 - + if testbase.db.dialect.supports_sane_rowcount(): + assert r.rowcount == 3 + def test_update_rowcount2(self): # WHERE matches 3, 0 rows changed department = employees_table.c.department r = employees_table.update(department=='C').execute(department='C') - assert r.rowcount == 3 - + if testbase.db.dialect.supports_sane_rowcount(): + assert r.rowcount == 3 + def test_delete_rowcount(self): # WHERE matches 3, 3 rows deleted department = employees_table.c.department r = employees_table.delete(department=='C').execute() - assert r.rowcount == 3 + if testbase.db.dialect.supports_sane_rowcount(): + assert r.rowcount == 3 if __name__ == '__main__': testbase.main() - + diff --git a/test/sql/testtypes.py b/test/sql/testtypes.py index acf21b917..b2b747a33 100644 --- a/test/sql/testtypes.py +++ b/test/sql/testtypes.py @@ -190,6 +190,11 @@ class UnicodeTest(AssertMixin): finally: db.engine.dialect.convert_unicode = prev_unicode + def testlength(self): + """checks the database correctly understands the length of a unicode string""" + teststr = u'aaa\x1234' + self.assert_(db.func.length(teststr).scalar() == len(teststr)) + class BinaryTest(AssertMixin): def setUpAll(self): global binary_table @@ -313,6 +318,24 @@ class DateTest(AssertMixin): #x = db.text("select * from query_users_with_date where user_datetime=:date", bindparams=[bindparam('date', )]).execute(date=datetime.datetime(2005, 11, 10, 11, 52, 35)).fetchall() #print repr(x) + @testbase.unsupported('sqlite') + def testdate2(self): + t = Table('testdate', testbase.metadata, Column('id', Integer, primary_key=True), + Column('adate', Date), Column('adatetime', DateTime)) + t.create() + try: + d1 = datetime.date(2007, 10, 30) + t.insert().execute(adate=d1, adatetime=d1) + d2 = datetime.datetime(2007, 10, 30) + t.insert().execute(adate=d2, adatetime=d2) + + x = t.select().execute().fetchall()[0] + self.assert_(x.adate.__class__ == datetime.date) + self.assert_(x.adatetime.__class__ == datetime.datetime) + + finally: + t.drop() + class TimezoneTest(AssertMixin): """test timezone-aware datetimes. psycopg will return a datetime with a tzinfo attached to it, if postgres returns it. python then will not let you compare a datetime with a tzinfo to a datetime |
