From: Mike Bayer Date: Sun, 14 Mar 2010 23:50:50 +0000 (-0400) Subject: fix failing test due to sybase paramstyle X-Git-Tag: rel_0_6beta2~54^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3ba365eea4984882f6f5f71aa97ac454bc7d96d;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git fix failing test due to sybase paramstyle --- diff --git a/CHANGES b/CHANGES index b33bf4b262..5a8cf7aac8 100644 --- a/CHANGES +++ b/CHANGES @@ -352,6 +352,13 @@ CHANGES compatible with the "func.current_date()", which will be returned as a string. [ticket:1685] +- sybase + - Implemented a preliminary working dialect for Sybase + based on the Python-Sybase driver. Handles table + creates/drops and basic round trip functionality. + Does not yet include reflection or comprehensive + support of unicode/special expressions/etc. + - examples - Changed the beaker cache example a bit to have a separate RelationCache option for lazyload caching. This object diff --git a/doc/build/dbengine.rst b/doc/build/dbengine.rst index 7aa306bb8a..5c61a67d8a 100644 --- a/doc/build/dbengine.rst +++ b/doc/build/dbengine.rst @@ -119,7 +119,7 @@ sqlite3_ ``sqlite+pysqlite``\* yes yes ------------------------------------------------------------------------------------------------------------------------------- mxodbc_ ``sybase+mxodbc`` development development no yes yes pyodbc_ ``sybase+pyodbc`` development development no unknown unknown -python-sybase_ ``sybase+pysybase``\* development development no yes yes +python-sybase_ ``sybase+pysybase``\* partial development no yes yes ========================= =========================== =========== =========== =========== ================= ============ .. _psycopg2: http://www.initd.org/ diff --git a/lib/sqlalchemy/test/engines.py b/lib/sqlalchemy/test/engines.py index 2f3d11bda6..58bfe2b3c1 100644 --- a/lib/sqlalchemy/test/engines.py +++ b/lib/sqlalchemy/test/engines.py @@ -80,10 +80,12 @@ def close_open_connections(fn): testing_reaper.close_all() return function_named(decorated, fn.__name__) -def all_dialects(): +def all_dialects(exclude=None): import sqlalchemy.databases as d for name in d.__all__: # TEMPORARY + if exclude and name in exclude: + continue mod = getattr(d, name, None) if not mod: mod = getattr(__import__('sqlalchemy.databases.%s' % name).databases, name) diff --git a/test/sql/test_functions.py b/test/sql/test_functions.py index 3ed5ee1458..1784af37f2 100644 --- a/test/sql/test_functions.py +++ b/test/sql/test_functions.py @@ -11,16 +11,14 @@ from sqlalchemy.test import * from sqlalchemy.sql.functions import GenericFunction from sqlalchemy.test.testing import eq_ from decimal import Decimal as _python_Decimal - +from sqlalchemy.test import testing from sqlalchemy.databases import * -# FIXME! -dialects = [d for d in all_dialects() if d.name not in ('access', 'informix')] - class CompileTest(TestBase, AssertsCompiledSQL): + def test_compile(self): - for dialect in dialects: + for dialect in all_dialects(exclude=('sybase', 'access', 'informix', 'maxdb')): bindtemplate = BIND_TEMPLATES[dialect.paramstyle] self.assert_compile(func.current_timestamp(), "CURRENT_TIMESTAMP", dialect=dialect) self.assert_compile(func.localtime(), "LOCALTIME", dialect=dialect) @@ -35,8 +33,12 @@ class CompileTest(TestBase, AssertsCompiledSQL): def __init__(self, arg, **kwargs): GenericFunction.__init__(self, args=[arg], **kwargs) - - self.assert_compile(fake_func('foo'), "fake_func(%s)" % bindtemplate % {'name':'param_1', 'position':1}, dialect=dialect) + + self.assert_compile( + fake_func('foo'), + "fake_func(%s)" % + bindtemplate % {'name':'param_1', 'position':1}, + dialect=dialect) def test_use_labels(self): self.assert_compile(select([func.foo()], use_labels=True), @@ -99,11 +101,13 @@ class CompileTest(TestBase, AssertsCompiledSQL): for fn in [func.coalesce, func.max, func.min, func.sum]: for args, type_ in [ - ((datetime.date(2007, 10, 5), datetime.date(2005, 10, 15)), sqltypes.Date), + ((datetime.date(2007, 10, 5), + datetime.date(2005, 10, 15)), sqltypes.Date), ((3, 5), sqltypes.Integer), ((_python_Decimal(3), _python_Decimal(5)), sqltypes.Numeric), (("foo", "bar"), sqltypes.String), - ((datetime.datetime(2007, 10, 5, 8, 3, 34), datetime.datetime(2005, 10, 15, 14, 45, 33)), sqltypes.DateTime) + ((datetime.datetime(2007, 10, 5, 8, 3, 34), + datetime.datetime(2005, 10, 15, 14, 45, 33)), sqltypes.DateTime) ]: assert isinstance(fn(*args).type, type_), "%s / %s" % (fn(), type_) @@ -141,10 +145,13 @@ class CompileTest(TestBase, AssertsCompiledSQL): self.assert_compile(func.lala.hoho(7), "lala.hoho(:hoho_1)") # test None becomes NULL - self.assert_compile(func.my_func(1,2,None,3), "my_func(:my_func_1, :my_func_2, NULL, :my_func_3)") + self.assert_compile(func.my_func(1,2,None,3), + "my_func(:my_func_1, :my_func_2, NULL, :my_func_3)") # test pickling - self.assert_compile(util.pickle.loads(util.pickle.dumps(func.my_func(1, 2, None, 3))), "my_func(:my_func_1, :my_func_2, NULL, :my_func_3)") + self.assert_compile( + util.pickle.loads(util.pickle.dumps(func.my_func(1, 2, None, 3))), + "my_func(:my_func_1, :my_func_2, NULL, :my_func_3)") # assert func raises AttributeError for __bases__ attribute, since its not a class # fixes pydoc @@ -269,7 +276,8 @@ class ExecuteTest(TestBase): eq_(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")] + assert select([t2.c.value, t2.c.stuff]).execute().fetchall() == \ + [(9,"some stuff"), (9,"some stuff"), (9,"some stuff")] t2.delete().execute()