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

hkeys() does not return all keys #131

Open
aschriner opened this issue Sep 23, 2015 · 1 comment
Open

hkeys() does not return all keys #131

aschriner opened this issue Sep 23, 2015 · 1 comment

Comments

@aschriner
Copy link

@select_query
def hkeys(self, query, attr):
"""
Enumerates the keys in the specified hstore.
"""
query.add_extra({'_': 'akeys("%s")' % attr}, None, None, None, None, None)
result = query.get_compiler(self.db).execute_sql(SINGLE)
return (result[0] if result else [])

I've verified in my own code that this is not returning all keys.

http://stackoverflow.com/questions/12015942/most-efficient-way-to-retrieve-a-unique-list-of-keys-from-all-rows-of-an-hstore

The hkeys() method probably needs a DISTINCT clause. Will follow up with a PR.

Update:

  • I'm trying to use hkeys on a queryset, which isn't mentioned in the docs. So I think I'm looking at adding functionality here rather than fixing a bug.
  • I'm trying to get tests running locally and I'm seeing some errors with dependencies. I've pip installed requirements.txt but still seeing stuff like django.core.exceptions.ImproperlyConfigured: GEOS is required and has not been detected. Are you sure it is installed? See also https://docs.djangoproject.com/en/1.8/ref/contrib/gis/install/geolibs/ Can you provide any info on how to get tests running locally, what needs to be installed, etc?
@nemesifier
Copy link
Member

You can run tests for psycopg only and avoid having to install the GIS libraries:

./runtests.py --settings=settings_psycopg

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

No branches or pull requests

2 participants