如何让 Django 2.0 使用 Oracle 11g 语法而不是 12c? [英] How to make Django 2.0 to use Oracle 11g syntax instead of 12c?
问题描述
这是我的开发环境:
- Windows 7 (x64)
- Python 3.6.3 64 位(虚拟环境)
- Django 2.0
- cx_Oracle 6.1
- Oracle 11.2 企业版 64 位(在远程机器上)
我未能migrate
(django manage.py migrate) 因为 Django 正在创建适用于 Oracle 12c 的 sql;但我使用的是 11g.
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?
回溯我在 ..Libsite-packagesdjangodbackendsoracleschema.py
(method _is_identity_column
, line151):
Tracing back the exception I found this in ..Libsite-packagesdjangodbackendsoracleschema.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?
推荐答案
来自 django 2.0 发行说明(重点是):
上游对 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屋!