]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed FB bug whereby a column default would fail to
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 6 Sep 2010 17:41:59 +0000 (13:41 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 6 Sep 2010 17:41:59 +0000 (13:41 -0400)
reflect if the "default" keyword were lower case.

CHANGES
lib/sqlalchemy/dialects/firebird/base.py
test/dialect/test_firebird.py

diff --git a/CHANGES b/CHANGES
index e58eb7e19e7116caf137015cd779baac6e8275c9..5a65d046a4a7e2b1838c181066596a0319b4101b 100644 (file)
--- 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.
index da8bef8c04e5c199f741675154a559770e27580a..bb4cc2b09428dbfb46e10f37cbeb23890b0c66c2 100644 (file)
@@ -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()
index a9b9fa2627f16bd337cc4c95c256097baf9de6b0..41a50e6a3baee4aad196f2a86ca77d883d2f629c 100644 (file)
@@ -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):