﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
30480	Discrepancy in `DateTime` field value If the django orm union() is used with the empty array in the filter.	Shashank Parekh	nobody	"{{{
class detail(models.Model):
      date_field = models.DateTimeField(null=True, index=True)
      guid = models.CharField(null=True, index=True)
      mobile = models.CharField(null=True, index=True)
      id = models.CharField(null=True, index=True)
}}}

{{{
p=detail.objects.filter(guid__in=[]).order_by('-date_field')
q=detail.objects.filter(mobile__in=['8970405058']).order_by('-date_field')
v = (p.union(q)).order_by('-date_field')
v[0].date_field   # Output is  '2018-10-08 12:51:39'.
}}}
** For this case, instead of getting datetime value, getting the string value.**


----


{{{
p=detail.objects.filter(guid__in=['some_garbage_value']).order_by('-date_field')
q=detail.objects.filter(mobile__in=['8970405058']).order_by('-date_field')
v = (p.union(q)).order_by('-date_field')
v[0].date_field .  # Output is datetime.datetime(2018, 10, 8, 12, 51, 39)
}}}
**If  I don't pass the empty array in filtering then getting the `DateTime` value.**

----

{{{
p=detail.objects.filter(guid__in=['some_garbage_value']).order_by('-date_field')
q=detail.objects.filter(mobile__in=['8970405058']).order_by('-date_field')
v = (p.union(q))
v[0].date_field .  # Output is datetime.datetime(2018, 10, 8, 12, 51, 39)
}}}
**If  I pass the empty array but withour `order_by` clause then getting the `DateTime` value.**


----

There is a discrepancy in `DateTime` field value If the union is used with the empty array in the filter."	Bug	closed	Database layer (models, ORM)	dev	Normal	worksforme			Unreviewed	0	0	0	0	0	0
