From: Mike Bayer Date: Fri, 31 Jul 2009 23:07:21 +0000 (+0000) Subject: added test for already fixed case of oracle alias name truncation being applied prope... X-Git-Tag: rel_0_6_6~51 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f7d7cb0ef1f001401d41e08b57f2d7cbbac9590;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git added test for already fixed case of oracle alias name truncation being applied properly, [ticket:1309] --- diff --git a/test/dialect/test_oracle.py b/test/dialect/test_oracle.py index c721133adb..730a3c7ace 100644 --- a/test/dialect/test_oracle.py +++ b/test/dialect/test_oracle.py @@ -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),