-
Notifications
You must be signed in to change notification settings - Fork 142
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
HSTORE adapter registration in psycopg2 conflicts with SQLAlchemy #45
Comments
Hi! Registering in each connection seems to be much overhead for normal use case, in my opinion, and per connection registering works well with connection pools because it register hstore on each connection retrieval from pool. (With https://github.com/djangonauts/djorm-ext-pool works well and it not requires special backend...) |
“Registering in each connection seems to be much overhead” — did you mean “in each cursor”? I agree (if that's what you meant) that per-connection makes more sense. The main thing is to get rid of |
Another settings like: 02d398c ? |
Yes @gthb! I was wrong! Additional config with good entry on documentation for notify about it for any sqlalchemy users seems a good solution... I'm currently very busy and I can't find time for it en almost three weeks :( |
[Edit: This comment was actually from @gthb, mistakenly logged in as DataMarket.] Me too : ) ... so I'll probably only do this if it becomes necessary to us to use HSTORE fields via Django. We don't need that (yet) so I just reported this and then backed out of using django-hstore for now. |
I was wondering... the settings instroduced in 02d398c is called HSTORE_GLOBAL_REGISTER, how would this setting be called? |
also, shouldn't this line https://github.com/djangonauts/django-hstore/blob/master/django_hstore/apps.py#L59 pass unique=HSTORE_GLOBAL_REGISTER too as in line https://github.com/djangonauts/django-hstore/blob/master/django_hstore/apps.py#L75? |
discussion should continue on #50 |
If both django_hstore and SQLAlchemy are used in the same Python process with psycopg2, then django_hstore's adapter registration will cause psycopg2 to return
HStoreDict
instances to SQLAlchemy, which expectsstr
. This causes errors likeAttributeError: 'HStoreDict' object has no attribute 'decode'
insqlalchemy/dialects/postgresql/hstore.py
:Some solution for the two to coexist would be good, for people who are using both Django and SQLAlchemy together.
One way might be to register the adapter only per connection/cursor, rather than globally (probably per cursor would be required for people using https://github.com/kennethreitz/django-postgrespool since the connections get shared).
The text was updated successfully, but these errors were encountered: