-
Notifications
You must be signed in to change notification settings - Fork 98
Open
Labels
bugSomething isn't workingSomething isn't working
Description
What happened?
in the center_summary view in coldfront.core.portal.views the query assigned to total_grants_by_agency_sum raises an error that prevents /center-summary from rendering properly.
The cause seems to be applying the Sum aggregation to the "total_amount_awarded" field, which is defined as aa a custom "Money" field in the model, which inherits from models.CharField. https://github.com/ubccr/coldfront/blob/main/coldfront/core/grant/models.py
In my case, I have no grants in the postgresql database.
Version
1.1.7
Component
Other
What browsers are you seeing the problem on?
Chrome
Relevant log output
Internal Server Error: /center-summary
Traceback (most recent call last):
File "/home/coldfront/coldfront/coldfront/.venv/lib/python3.12/site-packages/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.errors.UndefinedFunction: function sum(character varying) does not exist
LINE 1: SELECT "grant_grantfundingagency"."name", SUM("grant_grant"....
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/coldfront/coldfront/coldfront/.venv/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "/home/coldfront/coldfront/coldfront/.venv/lib/python3.12/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/coldfront/coldfront/coldfront/coldfront/core/portal/views.py", line 139, in center_summary
total_grants_by_agency_sum = list(
^^^^^
File "/home/coldfront/coldfront/coldfront/.venv/lib/python3.12/site-packages/django/db/models/query.py", line 398, in __iter__
self._fetch_all()
File "/home/coldfront/coldfront/coldfront/.venv/lib/python3.12/site-packages/django/db/models/query.py", line 1881, in _fetch_all
self._result_cache = list(self._iterable_class(self))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/coldfront/coldfront/coldfront/.venv/lib/python3.12/site-packages/django/db/models/query.py", line 208, in __iter__
for row in compiler.results_iter(
^^^^^^^^^^^^^^^^^^^^^^
File "/home/coldfront/coldfront/coldfront/.venv/lib/python3.12/site-packages/django/db/models/sql/compiler.py", line 1513, in results_iter
results = self.execute_sql(
^^^^^^^^^^^^^^^^^
File "/home/coldfront/coldfront/coldfront/.venv/lib/python3.12/site-packages/django/db/models/sql/compiler.py", line 1562, in execute_sql
cursor.execute(sql, params)
File "/home/coldfront/coldfront/coldfront/.venv/lib/python3.12/site-packages/django/db/backends/utils.py", line 67, in execute
return self._execute_with_wrappers(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/coldfront/coldfront/coldfront/.venv/lib/python3.12/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
return executor(sql, params, many, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/coldfront/coldfront/coldfront/.venv/lib/python3.12/site-packages/django/db/backends/utils.py", line 84, in _execute
with self.db.wrap_database_errors:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/coldfront/coldfront/coldfront/.venv/lib/python3.12/site-packages/django/db/utils.py", line 91, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/coldfront/coldfront/coldfront/.venv/lib/python3.12/site-packages/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django.db.utils.ProgrammingError: function sum(character varying) does not exist
LINE 1: SELECT "grant_grantfundingagency"."name", SUM("grant_grant"....
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
Tasks/ user tests when bug is fixed
no tests currently exist for this view.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working