From: Mike Bayer Date: Mon, 6 Sep 2010 17:41:59 +0000 (-0400) Subject: - Fixed FB bug whereby a column default would fail to X-Git-Tag: rel_0_6_4~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2bff7113888ed18f08b6c533cf223d6c53c5d46;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Fixed FB bug whereby a column default would fail to reflect if the "default" keyword were lower case. --- diff --git a/CHANGES b/CHANGES index e58eb7e19e..5a65d046a4 100644 --- a/CHANGES +++ b/CHANGES @@ -274,6 +274,10 @@ CHANGES - Fixed "default schema" query to work with pymssql backend. +- firebird + - Fixed bug whereby a column default would fail to + reflect if the "default" keyword were lower case. + - oracle - Added ROWID type to the Oracle dialect, for those cases where an explicit CAST might be needed. diff --git a/lib/sqlalchemy/dialects/firebird/base.py b/lib/sqlalchemy/dialects/firebird/base.py index da8bef8c04..bb4cc2b094 100644 --- a/lib/sqlalchemy/dialects/firebird/base.py +++ b/lib/sqlalchemy/dialects/firebird/base.py @@ -571,9 +571,10 @@ class FBDialect(default.DefaultDialect): if row['fdefault'] is not None: # the value comes down as "DEFAULT 'value'": there may be # more than one whitespace around the "DEFAULT" keyword + # and it may also be lower case # (see also http://tracker.firebirdsql.org/browse/CORE-356) defexpr = row['fdefault'].lstrip() - assert defexpr[:8].rstrip() == \ + assert defexpr[:8].rstrip().upper() == \ 'DEFAULT', "Unrecognized default value: %s" % \ defexpr defvalue = defexpr[8:].strip() diff --git a/test/dialect/test_firebird.py b/test/dialect/test_firebird.py index a9b9fa2627..41a50e6a3b 100644 --- a/test/dialect/test_firebird.py +++ b/test/dialect/test_firebird.py @@ -94,7 +94,8 @@ class DomainReflectionTest(TestBase, AssertsExecutionResults): class BuggyDomainReflectionTest(TestBase, AssertsExecutionResults): - "Test Firebird domains, see [ticket:1663] and http://tracker.firebirdsql.org/browse/CORE-356" + """Test Firebird domains (and some other reflection bumps), + see [ticket:1663] and http://tracker.firebirdsql.org/browse/CORE-356""" __only_on__ = 'firebird' @@ -167,6 +168,12 @@ CREATE DOMAIN DOM_ID INTEGER NOT NULL TABLE_A = """\ CREATE TABLE A ( ID DOM_ID /* INTEGER NOT NULL */ DEFAULT 0 ) +""" + + # the 'default' keyword is lower case here + TABLE_B = """\ +CREATE TABLE B ( +ID DOM_ID /* INTEGER NOT NULL */ default 0 ) """ @classmethod @@ -181,11 +188,13 @@ ID DOM_ID /* INTEGER NOT NULL */ DEFAULT 0 ) con.execute(cls.DOM_ID) con.execute(cls.TABLE_A) + con.execute(cls.TABLE_B) @classmethod def teardown_class(cls): con = testing.db.connect() con.execute('DROP TABLE a') + con.execute("DROP TABLE b") con.execute('DROP DOMAIN dom_id') con.execute('DROP TABLE def_error_nodom') con.execute('DROP TABLE def_error') @@ -213,7 +222,14 @@ ID DOM_ID /* INTEGER NOT NULL */ DEFAULT 0 ) table_a = Table('a', metadata, autoload=True) eq_(table_a.c.id.server_default.arg.text, "0") + + def test_lowercase_default_name(self): + metadata = MetaData(testing.db) + + table_b = Table('b', metadata, autoload=True) + eq_(table_b.c.id.server_default.arg.text, "0") + class CompileTest(TestBase, AssertsCompiledSQL):