python inspectdb got "The error was: function unnest(smallint[]) does not exist"

47 views
Skip to first unread message

weiwei...@keeptruckin.com

unread,
Jun 20, 2018, 1:14:24 PM6/20/18
to Django users
I use Amazon Redshift database and Django 2.0.6.   My redshift database settings is as below:

DATABASES = {

    'default': {

        'NAME': 'my_db_name',

        'ENGINE': 'django.db.backends.postgresql_psycopg2',

        'USER': 'my_username',

        'PASSWORD': 'my_password',

        'HOST': 'my_hostname',

        'PORT': 5439,

    },

}


When I run "python3 manage.py inspectdb", I got below error messages:


# Unable to inspect table 'eld_messages'

# The error was: function unnest(smallint[]) does not exist

HINT:  No function matches the given name and argument types. You may need to add explicit type casts.


Melvyn Sopacua

unread,
Jun 21, 2018, 3:58:31 AM6/21/18
to django...@googlegroups.com
On woensdag 20 juni 2018 19:12:00 CEST weiwei...@keeptruckin.com wrote:

> When I run "python3 manage.py inspectdb", I got below error messages:
>
>
> # Unable to inspect table 'eld_messages'
>
> # The error was: function unnest(smallint[]) does not exist
>
> HINT: No function matches the given name and argument types. You may need
> to add explicit type casts.

Unnest is a PostgreSQL specific array function, that doesn't have a counterpart
in Django's ORM, so Django does not know how to handle that.

In most cases I'd say, try to write a function for it, but in this case it may
be better to refactor the table. Do you know the function of the table and why
it would need an array of small ints stored? Can it be refactored to use
another table?
--
Melvyn Sopacua
Reply all
Reply to author
Forward
0 new messages