Error: Object of type datetime is not JSON serializable
matthew-a-dunlap opened this issue · 6 comments
Hello!
This project is great. I've run into an issue though. I was trying to run this (unfinished) query:
select m.id, m.pub_name, m.pub_id, m.contents_restricted,
array_agg(s.updated_at) as sub_dates
from main_manuscript m
left join main_submission s on m.id=s.manuscript_id
group by m.id, m.pub_name, m.pub_id, m.contents_restricted
order by m.id
The problem is that django-sql-dashboard errors out because it doesn't know how to serialize the s.updated_at
DateTime field for working with array_agg
.
As far as I could tell the only way to fix this would be to fork the codebase? Am I missing something? Thanks!
Definitely a bug!
Looks like this replicates the bug:
select ARRAY[now()]
Or this:
select TIMESTAMP WITH TIME ZONE '2004-10-19 10:23:54+02'
This works and returns a column called timestamptz
containing 2004-10-19 08:23:54+00:00
.
This does not work:
select ARRAY[TIMESTAMP WITH TIME ZONE '2004-10-19 10:23:54+02']
This is the code causing the error:
django-sql-dashboard/django_sql_dashboard/utils.py
Lines 53 to 56 in ea3c2be
OK, fix is out in 1.0.2: https://github.com/simonw/django-sql-dashboard/releases/tag/1.0.2
Awesome! Thanks so much :)