Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem With values_list in Haystack 2.x #1257

Closed
frank2411 opened this issue Oct 15, 2015 · 1 comment
Closed

Problem With values_list in Haystack 2.x #1257

frank2411 opened this issue Oct 15, 2015 · 1 comment
Labels

Comments

@frank2411
Copy link

When I do a values_list("field", flat=True) of a MultiValueField, populated with a list in a prepare_FOO method, it doesn't return like django, a unique list like [ x, y, z ...] but a list of lists like: [ [x,y,z], [x,y,z] ].

I don't know if you did this for some design purposes. But in my opinion, considering that .distinct() in haystack isn't supported, at least I could have/decide the correct format.

The problem for me exists because I've implemented a simple form of distinct, for values_list values using sets, and this format breaks all sets internal library automatisms, like erasing duplicated values.

To make this work I had to extend ValuesListSearchQuerySet ( That's not simple ) and I had to modify it's internal post_process_method to make this work even with values that are lists.

Finally keep on really good application.

@skirsdeda
Copy link

If you used Django's values_list on a multi-valued field, you would get the same list of lists. It's just that multivalued fields are not that common in standard SQL DBs. Try PostgreSQL arrays and you'll see. The idea with values_list is that you can specify more than one field and when flat=False you'll get list of field value lists, while with flat=True and only one field specified it's just one list. So use itertools chain or smth similar for your application. Marking this as wontfix and closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants