I am about to smash my head against the wall.
Consider the following piece of code:
def get_cardnumbers_from_timestamp(request, since_time=0):
if request.method == 'GET':
if request.user:
if not request.user.is_authenticated():
logger.debug('User is not authorized')
return auth_required('Authentication required')
logger.debug('User has been authorized')
user = request.user
logger.debug('since_time: {0}'.format(since_time))
if int(since_time) != 0:
utc_time = time.mktime(time.gmtime(int(since_time)))
else:
utc_time = 0
logger.debug('since_time UTC: {0}'.format(utc_time))
devices_data = dict()
from django.db import connection
cursor = connection.cursor()
query = 'SELECT c.name,c.id,d.locale,d.card_number,d.dev_uniqid,d.id FROM device_channel dc JOIN channels c on dc.channel_id = c.id JOIN devices d on dc.device_id=d.id WHERE d.card_number IS NOT NULL AND updated >= FROM_UNIXTIME({time}) ORDER BY d.id'.format(time=int(utc_time))
logger.debug(query)
cursor.execute(query)
answers = cursor.fetchall()
cursor.close()
logger.debug(answers)
Formed query, when fired against MySQL with since_time either explicitly set to 0 or not set at all returns about 250 rows, so does Django.
However, when I set the timestamp to a certain value, doesn't matter which one, same formed query (which I log and then copy-paste from the log) returns, say, 5 rows in MySQL console. Django gives me a result set of whopping 0.
I might be overlooking something very obvious, but I've already tried numerous approaches at this, to no avail.
Any ideas would be most welcome.