#24367: ORA-00918 (column ambiguously defined) when using a combination of 
slicing,
distinct, and order_by
-------------------------------------+-------------------------------------
     Reporter:  skoot                |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  1.7
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  ORA-00918 oracle     |             Triage Stage:
  queryset                           |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Kishor Pawar):

 * status:  closed => new
 * resolution:  fixed =>


Comment:

 I have models like (result of inspectdb)
 {{{
 class Profile(models.Model):
     id = models.BigIntegerField(primary_key=True)
     name = models.CharField(max_length=1024, blank=True, null=True)

     class Meta:
         managed = False
         db_table = 'cpe_profile'

 class ResourceMgmt(models.Model):
     id = models.BigIntegerField(primary_key=True)
     profile = models.ForeignKey(Profile, models.DO_NOTHING,
 related_name='cpe_mgmt_profile')

     class Meta:
         managed = False
         db_table = 'cpe_resource_mgmt'
 }}}

 Serializer like
 {{{
 class ResourceMgmtSerializer(serializers.ModelSerializer):
     profile_name = serializers.StringRelatedField(source='profile.name',
 read_only=True)

     class Meta:
         model = ResourceMgmt
         fields = (<tuple of fields including profile_name>)
 }}}

 View like
 {{{
 class RunningSchedules(generics.ListCreateAPIView):

     serializer_class = ResourceMgmtSerializer
     model = ResourceMgmt
     filter_backends = (filters.OrderingFilter, filters.SearchFilter,)
     ordering_fields = (<tuple of fields including profile_name as
 profile__name>)
     ordering = ('-schedule_start_time',)
     search_fields = ordering_fields
 }}}

 Now when I hit url like `?ordering=profile__name` I get an error
 `ORA-00918: column ambiguously defined`.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/24367#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.8f168867afc79ac0fb1f97c8b898c8e2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to