Ticket #3053: django_unambigous.patch

File django_unambigous.patch, 1.5 KB (added by Zoltan Arokszallasi <godri@…>, 18 years ago)
  • db/backends/oracle/query.py

    diff -ruN django.branch/db/backends/oracle/query.py django/db/backends/oracle/query.py
    old new  
    2323    Helper function that recursively populates the select, tables and where (in
    2424    place) for select_related queries.
    2525    """
    26     from django.db.models.fields import AutoField
    2726    qn = backend.quote_name
    2827    for f in opts.fields:
    2928        if f.rel and not f.null:
     
    3736            cache_tables_seen.append(db_table)
    3837            where.append('%s.%s = %s.%s' % \
    3938                (qn(old_prefix), qn(f.column), qn(db_table), qn(f.rel.get_related_field().column)))
    40             select.extend(['%s.%s' % (backend.quote_name(db_table), backend.quote_name(f2.column)) for f2 in f.rel.to._meta.fields if not isinstance(f2, AutoField)])
     39            select.extend(['%s.%s' % (backend.quote_name(db_table), backend.quote_name(f2.column)) for f2 in f.rel.to._meta.fields])
    4140            fill_table_cache(f.rel.to._meta, select, tables, where, db_table, cache_tables_seen)
    4241
    4342
     
    168167
    169168            # LIMIT and OFFSET clauses
    170169            # To support limits and offsets, Oracle requires some funky rewriting of an otherwise normal looking query.
    171             select_clause = ",".join(select)
     170            select_clause = ",".join(["%s as COLUMN#%s"%(select[i], i) for i in xrange(len(select))])
    172171            distinct = (self._distinct and "DISTINCT " or "")
    173172
    174173            if order_by:
Back to Top