Object mapper field selection issue using only().

1 view
Skip to first unread message

Charles-Antoine Dupont

unread,
May 15, 2016, 12:04:00 PM5/15/16
to DataStax Python Driver for Apache Cassandra User Mailing List
Hi,
I'm not sure if it is meant to be used, but the only way I have found to select certain fields of a model in query is to use .only(field_list)
e.g. model.objects.filter().only(field_list).all()

It seems to work, except I encountered a strange issue when filtering on a table with a partition key and two clustering key:

My specific case was similar to this one:
e.g. model.objects.filter(id__in=ids, other_text_field=some_string, start_date__gte=first_date, start_date__lt=end_date).only(field_list).all()
where  "id" is partition key, and other_text_field and start_date and clustering keys in that specific order.

For some reason, in that case, all fields will be returned, not just those in field_list.
However, if I create a table with no "other_text_field" and do not filter with it, the query is made with the fields in field_list.

I'm curious about the intent behind only() and if there is a way to make the driver more verbose as to what could've caused this behavior.

Thank you. 

Alan Boudreault

unread,
May 16, 2016, 10:30:32 AM5/16/16
to python-dr...@lists.datastax.com
Hello Charles-Antoine,

Thanks for reporting this. I investigated your use case and there is effectively a bug in the object mapper. The bug is related to the use of only() when defered fields are present. I´ve created a ticket and we will work on this as soon as possible. See the following link for more information:


Regards,
Alan

--
You received this message because you are subscribed to the Google Groups "DataStax Python Driver for Apache Cassandra User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-driver-u...@lists.datastax.com.



--

Alan Boudreault
Software Engineer (Drivers) | alan.bo...@datastax.com


Reply all
Reply to author
Forward
0 new messages