Django wagitail 后端 oracle 迁移 ORA-00907: 缺少右括号

Django wagitail backend oracle migrate ORA-00907: missing right parenthesis

Django 3.2.9 Oracle Database 12c 企业版 12.1.0.2.0 版 - 64 位生产 cx_Oracle8.3.0 Python3.7.6

我创建了一个新项目 Wagtail 并更改了 setting.py 数据库部分

DATABASES = {
# 'default': {
#     'ENGINE': 'django.db.backends.sqlite3',
#     'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
# }
'default': {
    'ENGINE': 'django.db.backends.oracle',
    'NAME': '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = XXX)(PORT = 1526)) (CONNECT_DATA = (SERVER = DEDICATED) (SID = XXXX)))',
    'USER': 'ZZZZZZ',
    'PASSWORD': 'ZZZZZZZ',
    'HOST': '',
    'PORT': '',
}

}

执行 python manage.py 迁移时显示此错误:

    WARNINGS:
wagtailcore.WorkflowState: (models.W036) Oracle does not support unique constraints with conditions.
        HINT: A constraint won't be created. Silence this warning if you don't care about it.
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, home, sessions, taggit, wagtailadmin, wagtailcore, wagtaildocs, wagtailembeds, wagtailforms, wagtailimages, wagtailredirects, wagtailsearch, wagtailusers
Running migrations:
  Applying wagtailcore.0059_apply_collection_ordering...Traceback (most recent call last):
  File "C:\Users\A262556\Documents\PROGETTI\prj-intranet-new\cms-prova\venv\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "C:\Users\A262556\Documents\PROGETTI\prj-intranet-new\cms-prova\venv\lib\site-packages\django\db\backends\oracle\base.py", line 523, in execute
    return self.cursor.execute(query, self._param_generator(params))
cx_Oracle.DatabaseError: ORA-00907: missing right parenthesis

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Users\A262556\Documents\PROGETTI\prj-intranet-new\cms-prova\venv\lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "C:\Users\A262556\Documents\PROGETTI\prj-intranet-new\cms-prova\venv\lib\site-packages\django\core\management\__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\A262556\Documents\PROGETTI\prj-intranet-new\cms-prova\venv\lib\site-packages\django\core\management\base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Users\A262556\Documents\PROGETTI\prj-intranet-new\cms-prova\venv\lib\site-packages\django\core\management\base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "C:\Users\A262556\Documents\PROGETTI\prj-intranet-new\cms-prova\venv\lib\site-packages\django\core\management\base.py", line 89, in wrapped
    res = handle_func(*args, **kwargs)
  File "C:\Users\A262556\Documents\PROGETTI\prj-intranet-new\cms-prova\venv\lib\site-packages\django\core\management\commands\migrate.py", line 246, in handle
    fake_initial=fake_initial,
  File "C:\Users\A262556\Documents\PROGETTI\prj-intranet-new\cms-prova\venv\lib\site-packages\django\db\migrations\executor.py", line 117, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "C:\Users\A262556\Documents\PROGETTI\prj-intranet-new\cms-prova\venv\lib\site-packages\django\db\migrations\executor.py", line 147, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "C:\Users\A262556\Documents\PROGETTI\prj-intranet-new\cms-prova\venv\lib\site-packages\django\db\migrations\executor.py", line 227, in apply_migration
    state = migration.apply(state, schema_editor)
  File "C:\Users\A262556\Documents\PROGETTI\prj-intranet-new\cms-prova\venv\lib\site-packages\django\db\migrations\migration.py", line 123, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "C:\Users\A262556\Documents\PROGETTI\prj-intranet-new\cms-prova\venv\lib\site-packages\django\db\migrations\operations\special.py", line 190, in database_forwards
    self.code(from_state.apps, schema_editor)
  File "C:\Users\A262556\Documents\PROGETTI\prj-intranet-new\cms-prova\venv\lib\site-packages\wagtail\core\migrations[=11=]59_apply_collection_ordering.py", line 15, in apply_collection_ordering
    Collection.fix_tree(fix_paths=True)
  File "C:\Users\A262556\Documents\PROGETTI\prj-intranet-new\cms-prova\venv\lib\site-packages\wagtail\core\treebeard.py", line 19, in fix_tree
    super().fix_tree(**kwargs)
  File "C:\Users\A262556\Documents\PROGETTI\prj-intranet-new\cms-prova\venv\lib\site-packages\treebeard\mp_tree.py", line 789, in fix_tree
    cursor.execute(sql, vals)
  File "C:\Users\A262556\Documents\PROGETTI\prj-intranet-new\cms-prova\venv\lib\site-packages\django\db\backends\utils.py", line 98, in execute
    return super().execute(sql, params)
  File "C:\Users\A262556\Documents\PROGETTI\prj-intranet-new\cms-prova\venv\lib\site-packages\django\db\backends\utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "C:\Users\A262556\Documents\PROGETTI\prj-intranet-new\cms-prova\venv\lib\site-packages\django\db\backends\utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "C:\Users\A262556\Documents\PROGETTI\prj-intranet-new\cms-prova\venv\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "C:\Users\A262556\Documents\PROGETTI\prj-intranet-new\cms-prova\venv\lib\site-packages\django\db\utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "C:\Users\A262556\Documents\PROGETTI\prj-intranet-new\cms-prova\venv\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "C:\Users\A262556\Documents\PROGETTI\prj-intranet-new\cms-prova\venv\lib\site-packages\django\db\backends\oracle\base.py", line 523, in execute
    return self.cursor.execute(query, self._param_generator(params))
django.db.utils.DatabaseError: ORA-00907: missing right parenthesis

哪个问题?我只更改数据库定义

django 版本可能是问题所在吗?来自 djangp 3.0 ?

迁移文件错误

# Generated by Django 3.1.1 on 2020-09-30 10:14

from django.db import migrations

# import the real Collection model (as opposed to the frozen version we'd obtain with
# apps.get_model) so that we can use its fix_tree method. Importing real models in migrations is
# generally avoided since it's liable to generate SQL queries according to the final migrated
# database state which we haven't reached yet - however, in this case it should be safe because
# fix_tree only touches the Treebeard-specific fields via values_list and update, and shouldn't be
# sensitive to schema changes elsewhere.
from wagtail.core.models import Collection


def apply_collection_ordering(apps, schema_editor):
    Collection.fix_tree(fix_paths=True)


class Migration(migrations.Migration):

    dependencies = [
        ('wagtailcore', '0058_page_alias_of'),
    ]

    operations = [
        migrations.RunPython(apply_collection_ordering, migrations.RunPython.noop),
    ]

根据https://github.com/wagtail/wagtail#compatibility,Wagtail 不正式支持 Oracle 作为数据库后端。

此处失败的特定查询是 django-treebeard library, which also does not support Oracle.

的一部分