summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-05-07 20:29:26 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-05-07 20:29:26 +0000
commite23c3a89742712c427c7e642186fc32263652530 (patch)
tree704ee033fcc55f2f58dc4f6c3b10542cf2644c26 /test/sql
parent6dd05dfb00cca205ffdcf6bdddcd77f368249ebb (diff)
downloadsqlalchemy-e23c3a89742712c427c7e642186fc32263652530.tar.gz
- fix to long name generation when using oid_column as an order by
(oids used heavily in mapper queries)
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/labels.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/test/sql/labels.py b/test/sql/labels.py
index 7d458da06..ee9fa6bc5 100644
--- a/test/sql/labels.py
+++ b/test/sql/labels.py
@@ -22,6 +22,7 @@ class LongLabelsTest(testbase.PersistTest):
Column("this_is_the_primarykey_column", Integer, Sequence("this_is_some_large_seq"), primary_key=True),
Column("this_is_the_data_column", String(30))
)
+
metadata.create_all()
def tearDown(self):
table1.delete().execute()
@@ -77,6 +78,17 @@ class LongLabelsTest(testbase.PersistTest):
q = table1.select(table1.c.this_is_the_primarykey_column == 4).alias('foo')
x = select([q])
print x.execute().fetchall()
-
+
+ def test_oid(self):
+ """test that a primary key column compiled as the 'oid' column gets proper length truncation"""
+ from sqlalchemy.databases import postgres
+ dialect = postgres.PGDialect()
+ dialect.max_identifier_length = lambda: 30
+ tt = table1.select(use_labels=True).alias('foo')
+ x = select([tt], use_labels=True, order_by=tt.oid_column).compile(dialect=dialect)
+ #print x
+ # assert it doesnt end with "ORDER BY foo.some_large_named_table_this_is_the_primarykey_column"
+ assert str(x).endswith("""ORDER BY foo.some_large_named_table_t_1""")
+
if __name__ == '__main__':
testbase.main()