]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
get basic compilation working for [ticket:972]
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 17 Feb 2008 15:35:30 +0000 (15:35 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 17 Feb 2008 15:35:30 +0000 (15:35 +0000)
lib/sqlalchemy/databases/informix.py
test/dialect/informix.py

index 400a2761e1e0f75f46c01d2cecc401ba7cf19b8e..d91b1b9b8f1a1b7a0523d66fee1f8fa662c7550d 100644 (file)
@@ -368,11 +368,12 @@ class InfoDialect(default.DefaultDialect):
 class InfoCompiler(compiler.DefaultCompiler):
     """Info compiler modifies the lexical structure of Select statements to work under
     non-ANSI configured Oracle databases, if the use_ansi flag is False."""
-    def __init__(self, dialect, statement, parameters=None, **kwargs):
+
+    def __init__(self, *args, **kwargs):
         self.limit = 0
         self.offset = 0
 
-        compiler.DefaultCompiler.__init__( self , dialect , statement , parameters , **kwargs )
+        compiler.DefaultCompiler.__init__( self , *args, **kwargs )
 
     def default_from(self):
         return " from systables where tabname = 'systables' "
@@ -401,7 +402,7 @@ class InfoCompiler(compiler.DefaultCompiler):
 
         # TODO: dont modify the original select, generate a new one
         a = [ __label(c) for c in select._raw_columns ]
-        for c in select.order_by_clause.clauses:
+        for c in select._order_by_clause.clauses:
             if ( __label(c) not in a ) and getattr( c , 'name' , '' ) != 'oid':
                 select.append_column( c )
 
index 4a2546f174f91c4c7bdfa8479c53ed96971f6ab8..1fbbaa0cb485dc9c4d6351d70aeb04c06ab11279 100644 (file)
@@ -4,12 +4,20 @@ from sqlalchemy.databases import informix
 from testlib import *
 
 
-class BasicTest(TestBase, AssertsExecutionResults):
-    # A simple import of the database/ module should work on all systems.
-    def test_import(self):
-        # we got this far, right?
-        return True
-
+class CompileTest(TestBase, AssertsCompiledSQL):
+    __dialect__ = informix.InfoDialect()
+    
+    def test_statements(self):
+        meta =MetaData()
+        t1= Table('t1', meta, Column('col1', Integer, primary_key=True), Column('col2', String(50)))
+        t2= Table('t2', meta, Column('col1', Integer, primary_key=True), Column('col2', String(50)), Column('col3', Integer, ForeignKey('t1.col1')))
+        
+        self.assert_compile(t1.select(), "SELECT t1.col1, t1.col2 FROM t1")
+    
+        self.assert_compile(select([t1, t2]).select_from(t1.join(t2)), "SELECT t1.col1, t1.col2, t2.col1, t2.col2, t2.col3 FROM t1 JOIN t2 ON t1.col1 = t2.col3")
 
+        self.assert_compile(t1.update().values({t1.c.col1 : t1.c.col1 + 1}), 'UPDATE t1 SET col1=(t1.col1 + ?)')
+        
+        
 if __name__ == "__main__":
     testenv.main()