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

Compatibility with django.postgres.HStoreField #76

Open
nemesifier opened this issue Oct 15, 2014 · 8 comments
Open

Compatibility with django.postgres.HStoreField #76

nemesifier opened this issue Oct 15, 2014 · 8 comments
Milestone

Comments

@nemesifier
Copy link
Member

How about stealing some improvements from this PR?
django/django#3219

:-)

It looks like the implementation is intentionally simple so to avoid complex code to achieve certain features.

So it probably make sense to take some improvements back into django-hstore.

Then if in PostgreSQL, the binary json type will really be merged with the hstore 2.0 features as it was announced few months ago, it could make sense to implement support for this new feature (binary json with hstore lookups and indexes) directly in this package which is already widely used.

@mjtamlyn
Copy link

mjtamlyn commented Nov 4, 2014

The most notable feature I'd like to see backported is the Operation subclass to add the extension, rather than requiring modification of the psql template. I've made slightly different choices as to which lookups and transforms to support, omitting the need for any custom managers. There are also some nice validators to provide a simpler version of your schema mode.

The implementation is intentionally simple, especially as a jsonb backed field will be coming after 9.4 final so we will have a similar data type which can handle non-string data.

@mjtamlyn
Copy link

mjtamlyn commented Nov 4, 2014

Oh, and thanks a lot for the connection_created signal handler code which is borrowed and simplified.

@nemesifier
Copy link
Member Author

👍 Thanks for reporting on the Operation subclass. That's surely something to check asap.

@nemesifier nemesifier mentioned this issue Jun 7, 2015
7 tasks
@nemesifier nemesifier changed the title New HStore field in django.postgres: steal some improvements? Compatibility with django.postgres.HStoreField Jun 28, 2015
@nemesifier nemesifier added this to the 2.0 milestone Jun 30, 2015
@RyanBalfanz
Copy link

+1

Any updates on this?

I agree with @mjtamlyn about the Operation. Access to the template dbs are not always available. For exmaple, I cannot use this project with Heroku's Review Apps, which is unfortunate. I also cannot run my tests (maybe related to #93).

The only workaround that sort of works now (for running tests) is to set HAS_STORE=False on the default database as in

# Workaround for `django.db.utils.ProgrammingError: hstore type not found in the database. please install it from your 'contrib/hstore.sql' file
DATABASES["default"]["HAS_HSTORE"] = False

The makes DATABASES["default"] read as if is does not have the extension, even though my migration will ensure that it in fact the database does has the hstore type, which could be misleading.

Here's the tail of the traceback:

…
The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "apiserver/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django/core/management/__init__.py", line 351, in execute_from_command_line
    utility.execute()
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django/core/management/__init__.py", line 343, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django/core/management/commands/test.py", line 30, in run_from_argv
    super(Command, self).run_from_argv(argv)
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django/core/management/base.py", line 394, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django/core/management/commands/test.py", line 74, in execute
    super(Command, self).execute(*args, **options)
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django/core/management/base.py", line 445, in execute
    output = self.handle(*args, **options)
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django/core/management/commands/test.py", line 90, in handle
    failures = test_runner.run_tests(test_labels)
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django/test/runner.py", line 210, in run_tests
    old_config = self.setup_databases()
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django/test/runner.py", line 166, in setup_databases
    **kwargs
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django/test/runner.py", line 370, in setup_databases
    serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True),
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django/db/backends/base/creation.py", line 368, in create_test_db
    test_flush=not keepdb,
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django/core/management/__init__.py", line 120, in call_command
    return command.execute(*args, **defaults)
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django/core/management/base.py", line 445, in execute
    output = self.handle(*args, **options)
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django/core/management/commands/migrate.py", line 93, in handle
    executor = MigrationExecutor(connection, self.migration_progress_callback)
  File "/Users/ryan/src/github.com/ShiftMedical/backend/.venv/lib/python3.5/site-packages/django/db/migrations/executor.py", line 19, in _init_
    self.loader = MigrationLoader(self.connection)
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django/db/migrations/loader.py", line 47, in _init_
    self.build_graph()
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django/db/migrations/loader.py", line 182, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django/db/migrations/recorder.py", line 59, in applied_migrations
    self.ensure_schema()
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django/db/migrations/recorder.py", line 49, in ensure_schema
    if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django/db/backends/base/base.py", line 164, in cursor
    cursor = self.make_cursor(self._cursor())
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django/db/backends/base/base.py", line 135, in cursor
    self.ensure_connection()
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django/db/backends/base/base.py", line 130, in ensure_connection
    self.connect()
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django/db/utils.py", line 97, in __exit_
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django/utils/six.py", line 658, in reraise
    raise value.with_traceback(tb)
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django/db/backends/base/base.py", line 130, in ensure_connection
    self.connect()
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django/db/backends/base/base.py", line 122, in connect
    connection_created.send(sender=self.__class__, connection=self)
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django/dispatch/dispatcher.py", line 201, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django_hstore/apps.py", line 62, in _call_
    return [x(connection) for x in handlers]
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django_hstore/apps.py", line 62, in <listcomp>
    return [x(connection) for x in handlers]
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/django_hstore/apps.py", line 90, in register_hstore_handler
    register_hstore(connection.connection, globally=HSTORE_REGISTER_GLOBALLY)
  File "/Users/ryan/src/github.com/backend/.venv/lib/python3.5/site-packages/psycopg2/extras.py", line 775, in register_hstore
    "hstore type not found in the database. "
django.db.utils.ProgrammingError: hstore type not found in the database. please install it from your 'contrib/hstore.sql' file
 Use --force to continue.

Aborted due to warnings.

@bufke
Copy link

bufke commented Oct 14, 2015

I'm using django 1.8 HStore field. I'd like to use that with this project (for perks like the admin widget, schema, ect). Is there anyway I can help with this task? It might be possible for me to pay someone already involved in the project to get this done. If you want to send me a private email it's david at burkesoftware dot com

@nemesifier
Copy link
Member Author

hi everybody, sorry for being very laggish but I'm very busy with other projects right now.

I invite more developers to step in and contribute to this project, the best way to do this is through the mailing list: https://groups.google.com/forum/#!forum/django-hstore

@bufke
Copy link

bufke commented Oct 14, 2015

Of course, we all get busy! Thanks for open sourcing the project and letting people use hstore before 1.8! I'll take a look at the code a bit.

Here's an existential question - does it make sense to add django's hstore to this project or break out features into their own addons for django? django-hstore-admin django-hstore-schema (those are what I'm most familiar with on this project)

@aleccool213
Copy link

aleccool213 commented May 27, 2016

@bufke
Super old question but I am actually using this project specifically for the admin interface and I think your idea is great. I also changed a few things with how this package depends on the native hstore when running migrations for the first time.

Will link to my fork of this project when complete.

Edit: https://github.com/bizxpro/django-hstore

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

No branches or pull requests

5 participants