Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#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 Mariusz Felisiak, 5 years ago

Component: Error reportingDatabase layer (models, ORM)
Owner: set to nobody
Resolution: needsinfo
Status: newclosed
Summary: ORA-00918: column ambiguously defined django adminORA-00918: column ambiguously defined django admin.

A simple Django project works for me. Please provide a sample (small) project to reproduce this issue.

comment:2 by Daniel Trizna, 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

Version 0, edited 5 years ago by Daniel Trizna (next)

comment:3 by Mariusz Felisiak, 5 years ago

Resolution: needsinfoinvalid

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.

Note: See TracTickets for help on using tickets.
Back to Top