We're getting this Oracle error from the Django line:
File "/home/aotemp/myvenv/lib/python3.8/site-packages/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
File "/home/aotemp/myvenv/lib/python3.8/site-packages/django/db/backends/oracle/base.py", line 556, in execute
return self.cursor.execute(query, self._param_generator(params))
cx_Oracle.DatabaseError: ORA-00918: column ambiguously defined
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/aotemp/myvenv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 56, in inner
response = get_response(request)
File "/home/aotemp/myvenv/lib/python3.8/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/aotemp/myvenv/lib/python3.8/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/home/aotemp/new-personality-server-2.0/personality/stores/views.py", line 154, in store_show
store_obj = Store.objects.select_related('address','brand','store_status','pos_app','timezone','business_line','store_type').get(id=pk)
File "/home/aotemp/myvenv/lib/python3.8/site-packages/django/db/models/query.py", line 646, in get
num = len(clone)
File "/home/aotemp/myvenv/lib/python3.8/site-packages/django/db/models/query.py", line 376, in __len__
self._fetch_all()
File "/home/aotemp/myvenv/lib/python3.8/site-packages/django/db/models/query.py", line 1867, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/home/aotemp/myvenv/lib/python3.8/site-packages/django/db/models/query.py", line 87, in __iter__
results = compiler.execute_sql(
File "/home/aotemp/myvenv/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1398, in execute_sql
cursor.execute(sql, params)
File "/home/aotemp/myvenv/lib/python3.8/site-packages/django/db/backends/utils.py", line 102, in execute
return super().execute(sql, params)
File "/home/aotemp/myvenv/lib/python3.8/site-packages/django/db/backends/utils.py", line 67, in execute
return self._execute_with_wrappers(
File "/home/aotemp/myvenv/lib/python3.8/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/aotemp/myvenv/lib/python3.8/site-packages/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
File "/home/aotemp/myvenv/lib/python3.8/site-packages/django/db/utils.py", line 91, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/aotemp/myvenv/lib/python3.8/site-packages/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
File "/home/aotemp/myvenv/lib/python3.8/site-packages/django/db/backends/oracle/base.py", line 556, in execute
return self.cursor.execute(query, self._param_generator(params))
django.db.utils.DatabaseError: ORA-00918: column ambiguously defined
The particular line of code that triggers it is:
store_obj = Store.objects.select_related('address','brand','store_status','pos_app','timezone','business_line','store_type').\
get(id=pk)
I understand that the error is an indication of the same column names in different tables, but for me the ORM is obscuring how to fix this problem in this case.
Any ideas? I'd appreciate any way to debug this that you have a suggestion.
Thanks.