如何使Django 2.0使用Oracle 11g语法而不是12c? [英] How to make Django 2.0 to use Oracle 11g syntax instead of 12c?

查看:102
本文介绍了如何使Django 2.0使用Oracle 11g语法而不是12c?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的开发环境:

  • Windows 7(x64)
  • Python 3.6.3 64位(虚拟环境)
  • Django 2.0
  • cx_Oracle 6.1
  • Oracle 11.2企业版64位(在远程计算机上)

我无法执行migrate(django manage.py migration ),因为Django正在创建适用于Oracle 12c的sql;但我使用的是11克.

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

例如,django尝试执行此操作:

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']

但是列identity_column在oracle 11g上不可用.

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

如何使Django使用11g语法?

How can I make django use 11g syntax?

追溯异常,这是我在..\Lib\site-packages\django\db\backends\oracle\schema.py(方法_is_identity_column,第151行)中发现的:

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)])

因此语法是硬编码的.这是否意味着Django 2.0适用于Oracle 12c及更高版本?

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

推荐答案

来自

对Oracle 11.2的上游支持的终止于2020年12月.Django 1.11 支持将一直持续到2020年4月,直到这一日期为止. Django 2.0正式支持Oracle 12.1 + .

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+.

因此,要支持任何其他版本的Oracle,您应将其降级至1.11

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

这篇关于如何使Django 2.0使用Oracle 11g语法而不是12c?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆