1. Marc Abramowitz
  2. sqlalchemy

Commits

Mike Bayer  committed 443b974

- Fixed FB bug whereby a column default would fail to
reflect if the "default" keyword were lower case.

  • Participants
  • Parent commits 77df7d5
  • Branches default

Comments (0)

Files changed (3)

File CHANGES

View file
  • Ignore whitespace
   - 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.

File lib/sqlalchemy/dialects/firebird/base.py

View file
  • Ignore whitespace
             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()

File test/dialect/test_firebird.py

View file
  • Ignore whitespace
 
 
 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'
 
 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
     def setup_class(cls):
 
         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')
         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):