#31264 closed Bug (invalid)
ORA-00918: column ambiguously defined django admin.
Reported by: | Daniel Trizna | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 3.0 |
Severity: | Normal | Keywords: | oracle, django admin |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When I start brand new project using django 3.0.3 and oracle database after migrating basic schemas the django admin throw following error:
ORA-00918: column ambiguously defined django admin ... meanwhile when i switched django to django 2.* the issue disappeared. I guess there is a problem with generating sql querry.
Change History (3)
comment:1 by , 5 years ago
Component: | Error reporting → Database layer (models, ORM) |
---|---|
Owner: | set to |
Resolution: | → needsinfo |
Status: | new → closed |
Summary: | ORA-00918: column ambiguously defined django admin → ORA-00918: column ambiguously defined django admin. |
comment:2 by , 5 years ago
I am affraid that i can not provide you with the project i am working on but i replicated when i started a new project and replaced the database dictionary with my custom dictionary like this:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.oracle',
'NAME': "VALID NAME",
'USER': "username",
'PASSWORD': "password",
}
}
when i use 'django_sqlprint_middleware.SqlPrintMiddleware' plugin i am able to get the sql querry that the django admin is executing.
in django 2.* the querry was :
QUERY = 'SELECT * FROM (SELECT "_SUB".* FROM (SELECT "DJANGO_ADMIN_LOG"."ID" AS Col1, "DJANGO_ADMIN_LOG"."ACTION_TIME" AS Col2, "DJANGO_ADMIN_LOG"."USER_ID" AS Col3, "DJANGO_ADMIN_LOG"."CONTENT_TYPE_ID" AS Col4, "DJANGO_ADMIN_LOG"."OBJECT_ID" AS Col5, "DJANGO_ADMIN_LOG"."OBJECT_REPR" AS Col6, "DJANGO_ADMIN_LOG"."ACTION_FLAG" AS Col7, "DJANGO_ADMIN_LOG"."CHANGE_MESSAGE" AS Col8, "AUTH_USER"."ID" AS Col9, "AUTH_USER"."PASSWORD" AS Col10, "AUTH_USER"."LAST_LOGIN" AS Col11, "AUTH_USER"."IS_SUPERUSER" AS Col12, "AUTH_USER"."USERNAME" AS Col13, "AUTH_USER"."FIRST_NAME" AS Col14, "AUTH_USER"."LAST_NAME" AS Col15, "AUTH_USER"."EMAIL" AS Col16, "AUTH_USER"."IS_STAFF" AS Col17, "AUTH_USER"."IS_ACTIVE" AS Col18, "AUTH_USER"."DATE_JOINED" AS Col19, "DJANGO_CONTENT_TYPE"."ID" AS Col20, "DJANGO_CONTENT_TYPE"."APP_LABEL" AS Col21, "DJANGO_CONTENT_TYPE"."MODEL" AS Col22 FROM "DJANGO_ADMIN_LOG" INNER JOIN "AUTH_USER" ON ("DJANGO_ADMIN_LOG"."USER_ID" = "AUTH_USER"."ID") LEFT OUTER JOIN "DJANGO_CONTENT_TYPE" ON ("DJANGO_ADMIN_LOG"."CONTENT_TYPE_ID" = "DJANGO_CONTENT_TYPE"."ID") WHERE "DJANGO_ADMIN_LOG"."USER_ID" = :arg0 ORDER BY "DJANGO_ADMIN_LOG"."ACTION_TIME" DESC) "_SUB" WHERE ROWNUM <= 10)' - PARAMS = (1,)
where all columns have their aliases.
In django 3 the querry is as follows :
SELECT "DJANGO_ADMIN_LOG"."ID", "DJANGO_ADMIN_LOG"."ACTION_TIME", "DJANGO_ADMIN_LOG"."USER_ID", "DJANGO_ADMIN_LOG"."CONTENT_TYPE_ID", "DJANGO_ADMIN_LOG"."OBJECT_ID", "DJANGO_ADMIN_LOG"."OBJECT_REPR", "DJANGO_ADMIN_LOG"."ACTION_FLAG", "DJANGO_ADMIN_LOG"."CHANGE_MESSAGE", "AUTH_USER"."ID", "AUTH_USER"."PASSWORD", "AUTH_USER"."LAST_LOGIN", "AUTH_USER"."IS_SUPERUSER", "AUTH_USER"."USERNAME", "AUTH_USER"."FIRST_NAME", "AUTH_USER"."LAST_NAME", "AUTH_USER"."EMAIL", "AUTH_USER"."IS_STAFF", "AUTH_USER"."IS_ACTIVE", "AUTH_USER"."DATE_JOINED", "DJANGO_CONTENT_TYPE"."ID", "DJANGO_CONTENT_TYPE"."APP_LABEL", "DJANGO_CONTENT_TYPE"."MODEL"
FROM "DJANGO_ADMIN_LOG"
INNER JOIN "AUTH_USER"
ON (
"DJANGO_ADMIN_LOG"."USER_ID" = "AUTH_USER"."ID"
)
LEFT OUTER JOIN "DJANGO_CONTENT_TYPE"
ON (
"DJANGO_ADMIN_LOG"."CONTENT_TYPE_ID" = "DJANGO_CONTENT_TYPE"."ID"
)
WHERE "DJANGO_ADMIN_LOG"."USER_ID" = 1 ORDER BY "DJANGO_ADMIN_LOG"."ACTION_TIME" DESC FETCH FIRST 10 ROWS ONLY
the columns does not have aliases and as a result there are 3 columns named id which causes the problem
comment:3 by , 5 years ago
Resolution: | needsinfo → invalid |
---|
This issue was described in #29630, it's a bug in Oracle 12.1. Workaround was removed in Django 3.0 because it doesn't support Oracle 12.1 anymore.
A simple Django project works for me. Please provide a sample (small) project to reproduce this issue.