bernardopires / django-tenant-schemas

Tenant support for Django using PostgreSQL schemas.
https://django-tenant-schemas.readthedocs.org/en/latest/
MIT License
1.46k stars 423 forks source link

Tests fail when running against PostgreSQL version 9.6 #405

Closed goodtune closed 8 years ago

goodtune commented 8 years ago

Running the test suite against all the available versions of PostgreSQL that are up on Docker Hub revealed that the project is not presently compatible with version 9.6.

Starting the test database is really easy!

docker run --rm --env POSTGRES_USER=$USER postgres:9.6

This will leave it in the foreground, making any logs easy to capture... as below.

PostgreSQL init process complete; ready for start up.

LOG:  database system was shut down at 2016-11-10 08:02:29 UTC
LOG:  MultiXact member wraparound protections are now enabled
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started

Kicking off the test case in the usual manner via tox yielded the problem below from the database.

ERROR:  column am.amcanorder does not exist at character 497
STATEMENT:  
            SELECT
                    indexname, array_agg(attname), indisunique, indisprimary,
                    array_agg(ordering), amname, exprdef
                FROM (
                    SELECT
                        c2.relname as indexname, idx.*, attr.attname, am.amname,
                        CASE
                            WHEN idx.indexprs IS NOT NULL THEN
                                pg_get_indexdef(idx.indexrelid)
                        END AS exprdef,
                        CASE
                            WHEN am.amcanorder THEN
                                CASE (option & 1)
                                    WHEN 1 THEN 'DESC' ELSE 'ASC'
                                END
                        END as ordering
                    FROM (
                        SELECT
                            *, unnest(i.indkey) as key, unnest(i.indoption) as option
                        FROM pg_index i
                    ) idx
                        LEFT JOIN pg_class c ON idx.indrelid = c.oid
                        LEFT JOIN pg_class c2 ON idx.indexrelid = c2.oid
                        LEFT JOIN pg_am am ON c2.relam = am.oid
                        LEFT JOIN pg_attribute attr ON attr.attrelid = c.oid AND attr.attnum = idx.key
                        LEFT JOIN pg_namespace n ON c.relnamespace = n.oid
                    WHERE c.relname = 'dts_test_app_dummymodel'
                      AND n.nspname = 'test'
                ) s2
                GROUP BY indexname, indisunique, indisprimary, amname, exprdef;

I am not familiar with the pg_am table - was it replaced in v9.6?

bernardopires commented 8 years ago

Seems like some fields were removed in 9.6

https://www.postgresql.org/docs/9.5/static/catalog-pg-am.html https://www.postgresql.org/docs/9.6/static/catalog-pg-am.html

https://www.postgresql.org/docs/9.6/static/release-9-6.html

Restructure index access method API to hide most of it at the C level (Alexander Korotkov, Andrew Gierth)

This change modernizes the index AM API to look more like the designs we have adopted for foreign data wrappers and tablesample handlers. This simplifies the C code and makes it much more practical to define index access methods in installable extensions. A consequence is that most of the columns of the pg_am system catalog have disappeared. New inspection functions have been added to allow SQL queries to determine index AM properties that used to be discoverable from pg_am.

goodtune commented 8 years ago

Thanks for the patch @jprashanth - I looked at updating the .travis.yml to run the test suite against v9.6 but it's not one of the supported versions.

rvignesh89 commented 7 years ago

@goodtune does this mean tenant schema can be used in PostgreSQL 9.6?

goodtune commented 7 years ago

Yes, PostgreSQL 9.6 is supported.

mcanaves commented 7 years ago

@goodtune I tried to run the tests under PostgreSQL 9.6 and Python 2.7 and one test still failing. With Python 3.5 works perfect.