From: Jason Kirtland Date: Mon, 19 May 2008 19:37:44 +0000 (+0000) Subject: - Implemented generic CHAR_LENGTH for sqlite (-> LENGTH()) X-Git-Tag: rel_0_5beta1~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ced326dc1f8f60c97887d2735ca22b31520d93a5;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Implemented generic CHAR_LENGTH for sqlite (-> LENGTH()) - Updated .requires for firebird --- diff --git a/lib/sqlalchemy/databases/sqlite.py b/lib/sqlalchemy/databases/sqlite.py index 98e2acbf43..1b85fb016d 100644 --- a/lib/sqlalchemy/databases/sqlite.py +++ b/lib/sqlalchemy/databases/sqlite.py @@ -393,7 +393,8 @@ class SQLiteCompiler(compiler.DefaultCompiler): functions = compiler.DefaultCompiler.functions.copy() functions.update ( { - sql_functions.now: 'CURRENT_TIMESTAMP' + sql_functions.now: 'CURRENT_TIMESTAMP', + sql_functions.char_length: 'length%(expr)s' } ) diff --git a/test/orm/unitofwork.py b/test/orm/unitofwork.py index a58bfa0e5a..926dc6ff07 100644 --- a/test/orm/unitofwork.py +++ b/test/orm/unitofwork.py @@ -1,5 +1,4 @@ # coding: utf-8 - """Tests unitofwork operations.""" import testenv; testenv.configure_for_tests() @@ -8,7 +7,7 @@ import operator from sqlalchemy.orm import mapper as orm_mapper from testlib import engines, sa, testing -from testlib.sa import Table, Column, Integer, String, ForeignKey, Index +from testlib.sa import Table, Column, Integer, String, ForeignKey from testlib.sa.orm import mapper, relation, create_session from testlib.testing import eq_, ne_ from testlib.compat import set @@ -818,8 +817,6 @@ class DefaultTest(_base.MappedTest): """ - __unsupported_on__ = ('firebird',) # can't pass arg to func.length - def define_tables(self, metadata): use_string_defaults = testing.against('postgres', 'oracle', 'sqlite') @@ -839,7 +836,7 @@ class DefaultTest(_base.MappedTest): Column('id', Integer, primary_key=True, test_needs_autoincrement=True), Column('hoho', hohotype, server_default=str(hohoval), unique=True), - Column('counter', Integer, default=sa.func.length("1234567")), + Column('counter', Integer, default=sa.func.char_length("1234567")), Column('foober', String(30), default="im foober", onupdate="im the update")) @@ -864,6 +861,7 @@ class DefaultTest(_base.MappedTest): class Secondary(_base.ComparableEntity): pass + @testing.fails_on('firebird') # "Data type unknown" on the parameter @testing.resolve_artifact_names def test_insert(self): mapper(Hoho, default_t) @@ -908,6 +906,7 @@ class DefaultTest(_base.MappedTest): self.assert_(h2.foober == h3.foober == h4.foober == 'im foober') eq_(h5.foober, 'im the new foober') + @testing.fails_on('firebird') # "Data type unknown" on the parameter @testing.resolve_artifact_names def test_eager_defaults(self): mapper(Hoho, default_t, eager_defaults=True) @@ -937,6 +936,7 @@ class DefaultTest(_base.MappedTest): eq_(h1.foober, "im foober") self.sql_count_(0, go) + @testing.fails_on('firebird') # "Data type unknown" on the parameter @testing.resolve_artifact_names def test_update(self): mapper(Hoho, default_t) @@ -951,6 +951,7 @@ class DefaultTest(_base.MappedTest): session.flush() eq_(h1.foober, 'im the update') + @testing.fails_on('firebird') # "Data type unknown" on the parameter @testing.resolve_artifact_names def test_used_in_relation(self): """A server-side default can be used as the target of a foreign key""" @@ -2144,8 +2145,6 @@ class RowSwitchTest(_base.MappedTest): class TransactionTest(_base.MappedTest): __requires__ = ('deferrable_constraints',) - __unsupported_on__ = ('firebird',) # has no deferred - __whitelist__ = ('sqlite',) # sqlite doesn't have deferrable constraints, but it allows them to # be specified. it'll raise immediately post-INSERT, instead of at diff --git a/test/testlib/requires.py b/test/testlib/requires.py index a382f42bc5..f5746da8f3 100644 --- a/test/testlib/requires.py +++ b/test/testlib/requires.py @@ -15,6 +15,7 @@ def deferrable_constraints(fn): """Target database must support derferable constraints.""" return _chain_decorators_on( fn, + no_support('firebird', 'not supported by database'), no_support('mysql', 'not supported by database'), no_support('mssql', 'not supported by database'), )