Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Django 2.0 to use Oracle 11g syntax instead of 12c?

This is my dev environment:

  • Windows 7 (x64)
  • Python 3.6.3 64bit (virtual environment)
  • Django 2.0
  • cx_Oracle 6.1
  • Oracle 11.2 Enterprise Edition 64 bit (on remote machine)

I am failing to migrate (django manage.py migrate) because Django is creating sql suitable for Oracle 12c; but I am using 11g.

For example, django tries to execute this:

SELECT
CASE WHEN identity_column = 'YES' THEN 1 ELSE 0 END
FROM user_tab_cols
WHERE table_name = 'DJANGO_CONTENT_TYPE' AND
column_name = 'NAME';
('DJANGO_CONTENT_TYPE', 'NAME'); 
args=['DJANGO_CONTENT_TYPE', 'NAME']

But the column identity_column is not available on oracle 11g.

How can I make django use 11g syntax?

EDIT:

Tracing back the exception I found this in ..\Lib\site-packages\django\db\backends\oracle\schema.py(method _is_identity_column, line 151):

cursor.execute("""
                SELECT
                    CASE WHEN identity_column = 'YES' THEN 1 ELSE 0 END
                FROM user_tab_cols
                WHERE table_name = %s AND
                      column_name = %s
            """, [self.normalize_name(table_name), self.normalize_name(column_name)])

So the syntax is hard coded. Does this mean Django 2.0 is for Oracle 12c an onwards?

like image 208
mshsayem Avatar asked Jan 29 '23 23:01

mshsayem


1 Answers

From the release notes of django 2.0 (with my emphasis):

The end of upstream support for Oracle 11.2 is Dec. 2020. Django 1.11 will be supported until April 2020 which almost reaches this date. Django 2.0 officially supports Oracle 12.1+.

So, for support of any other version of Oracle, you should downgrade to 1.11

like image 97
Burhan Khalid Avatar answered Feb 08 '23 17:02

Burhan Khalid