]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
added test for already fixed case of oracle alias name truncation being applied prope...
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 31 Jul 2009 23:07:21 +0000 (23:07 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 31 Jul 2009 23:07:21 +0000 (23:07 +0000)
test/dialect/test_oracle.py

index c721133adbab0f763f1302f827fe09a060086a55..730a3c7ace4a48ad68aba9c31ea936ffcee6c0b9 100644 (file)
@@ -8,6 +8,7 @@ from sqlalchemy.test import *
 from sqlalchemy.test.testing import eq_
 from sqlalchemy.test.engines import testing_engine
 from sqlalchemy.dialects.oracle import cx_oracle, base as oracle
+from sqlalchemy.engine import default
 import os
 
 
@@ -88,7 +89,57 @@ class CompileTest(TestBase, AssertsCompiledSQL):
         self.assert_compile(s, "SELECT col1, col2 FROM (SELECT col1, col2, ROWNUM "
             "AS ora_rn FROM (SELECT sometable.col1 AS col1, sometable.col2 AS col2 FROM sometable "
             "ORDER BY sometable.col2) WHERE ROWNUM <= :ROWNUM_1) WHERE ora_rn > :ora_rn_1")
+    
+    def test_long_labels(self):
+        dialect = default.DefaultDialect()
+        dialect.max_identifier_length = 30
+        
+        ora_dialect = oracle.dialect()
+        
+        m = MetaData()
+        a_table = Table(
+            'thirty_characters_table_xxxxxx',
+            m,
+            Column('id', Integer, primary_key=True)
+        )
 
+        other_table = Table(
+            'other_thirty_characters_table_',
+            m,
+            Column('id', Integer, primary_key=True),
+            Column('thirty_characters_table_id',
+                Integer,
+                ForeignKey('thirty_characters_table_xxxxxx.id'),
+                primary_key=True
+            )
+        )
+        
+        anon = a_table.alias()
+        self.assert_compile(
+        
+            select([other_table, anon]).select_from(
+                other_table.outerjoin(anon)
+            ).apply_labels(),
+            "SELECT other_thirty_characters_table_.id AS other_thirty_characters__1, "
+            "other_thirty_characters_table_.thirty_characters_table_id AS other_thirty_characters__2, "
+            "thirty_characters_table__1.id AS thirty_characters_table__3 FROM other_thirty_characters_table_ "
+            "LEFT OUTER JOIN thirty_characters_table_xxxxxx AS thirty_characters_table__1 ON "
+            "thirty_characters_table__1.id = other_thirty_characters_table_.thirty_characters_table_id",
+            dialect=dialect
+        )
+        self.assert_compile(
+        
+            select([other_table, anon]).select_from(
+                other_table.outerjoin(anon)
+            ).apply_labels(),
+            "SELECT other_thirty_characters_table_.id AS other_thirty_characters__1, "
+            "other_thirty_characters_table_.thirty_characters_table_id AS other_thirty_characters__2, "
+            "thirty_characters_table__1.id AS thirty_characters_table__3 FROM other_thirty_characters_table_ "
+            "LEFT OUTER JOIN thirty_characters_table_xxxxxx thirty_characters_table__1 ON "
+            "thirty_characters_table__1.id = other_thirty_characters_table_.thirty_characters_table_id",
+            dialect=ora_dialect
+        )
+        
     def test_outer_join(self):
         table1 = table('mytable',
             column('myid', Integer),