Working with HstoreField in django tests

61 views
Skip to first unread message

Denis Boyarkin

unread,
May 15, 2016, 9:11:33 PM5/15/16
to Django users

I'm using HstoreField in one of my models and when I try to test it I got an error psycopg2.ProgrammingError: ERROR: function hstore(integer[], text[]) does not exist. If I understand this problem correctly it happend because hstore extension wasn't setup in database as it was did in migrations by adding HStoreExtension operation (documentation).

How to setup hstore extension in default test database and solve my problem?

Simon Charette

unread,
May 15, 2016, 9:22:50 PM5/15/16
to Django users
Hi Denis,

From the exception it looks like the issue is not related to a missing extension
but from an attempt of using and integer as a key. e.g.

instance.hstore_field = {1: 'foo'}

instead of

instance.hstore_field = {'1': 'foo'}

Cheers,
Simon

Denis Boyarkin

unread,
May 16, 2016, 12:55:08 AM5/16/16
to Django users
Yes, It helped, thank you. If you're on Stackowerflow you can answer this question:this question.

понедельник, 16 мая 2016 г., 9:22:50 UTC+8 пользователь Simon Charette написал:
Reply all
Reply to author
Forward
0 new messages