5

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?

mshsayem
  • 17,557
  • 11
  • 61
  • 69
  • I don't know. Just being curious: what errors do you get? I'd expect vast majority of SQL statements to work on both releases. – Littlefoot Dec 28 '17 at 07:07
  • @Littlefoot I have posted a sample sql. – mshsayem Dec 28 '17 at 08:00
  • Can you comment that code? As you've said, there's no IDENTITY_COLUMN in 11g's USER_TAB_COLS. Or, perhaps, "hardcode" it to return 0 (as there's no identity column in 11g either, it was introduced in 12c). Such as "SELECT 0 FROM USER_TAB_COLS WHERE ..." – Littlefoot Dec 28 '17 at 08:32

1 Answers1

9

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

Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284