summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoulder Sprinters <boulder-sprinters@djangoproject.com>2007-01-03 19:17:58 +0000
committerBoulder Sprinters <boulder-sprinters@djangoproject.com>2007-01-03 19:17:58 +0000
commit68aaa5df72ba3002f822e97f986e049d8a86613c (patch)
treeafdb8a3213531908e606d7d4d6538ffd02fa160f
parent58ba520f32821140c96725b1f68ff31d64751844 (diff)
boulder-oracle-sprint: Fixed "ORA-00918 : column ambiguously defined" errors by aliasing columns with duplicated names.
git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@4277 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/db/backends/oracle/query.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/django/db/backends/oracle/query.py b/django/db/backends/oracle/query.py
index bb56af51ec..db041607cc 100644
--- a/django/db/backends/oracle/query.py
+++ b/django/db/backends/oracle/query.py
@@ -134,6 +134,16 @@ def get_query_set_class(DefaultQuerySet):
if order_by:
sql.append("ORDER BY " + ", ".join(order_by))
+ # Look for column name collisions in the select elements
+ # and fix them with an AS alias. This allows us to do a
+ # SELECT * later in the paging query.
+ cols = [clause.split('.')[-1] for clause in select]
+ for index, col in enumerate(cols):
+ if cols.count(col) > 1:
+ col = '%s%d' % (col.replace('"', ''), index)
+ cols[index] = col
+ select[index] = '%s AS %s' % (select[index], col)
+
# LIMIT and OFFSET clauses
# To support limits and offsets, Oracle requires some funky rewriting of an otherwise normal looking query.
select_clause = ",".join(select)