I have created a little test app to track down a problem I experienced with Postgres on Heroku: http://snippi.com/s/xd511rf
As you can see in line 49, I want to retrieve all entries created today. This would be the first two items of my test data with the Ruby Gem DataMapper.
When I run this app on my notebook (Ubuntu 12.10, HP, Ruby 1.9.3) everything I get this result, which is right:
[
{
"id": 1,
"text": "Working on some awsomenewss",
"category": 0,
"starttime": "2013-03-21T15:56:00+01:00",
"endtime": "2013-03-21T18:26:00+01:00",
"creation": "2013-03-21T16:15:21+01:00"
},
{
"id": 2,
"text": "facebooking",
"category": 0,
"starttime": "2013-03-21T20:48:00+01:00",
"endtime": "2013-03-21T22:26:00+01:00",
"creation": "2013-03-21T16:15:21+01:00"
}
]
In my debug console this SQL query is logged:
SELECT "id", "text", "category", "starttime", "endtime", "creation"
FROM "entries"
WHERE "starttime"
BETWEEN '2013-03-21T00:00:00+00:00'
AND '2013-03-21T23:59:59+00:00'
ORDER BY "id"
But after pushing the app to Heroku a very strange error occurrs. When I run it now (http://afternoon-everglades-4239.herokuapp.com/) this is the response:
[]
Why is it empty?
The data is definitely in the database which is proved by this Dataclip from Heroku: https://dataclips.heroku.com/hygziosyxwperyctwfbhjzgbzhbj
Also when I run the SQL command manually via ´heroku pg:psql´ it actually works with this output:
id | text | category | starttime | endtime | creation ----+-----------------------------+----------+---------------------+---------------------+--------------------- 1 | Working on some awsomenewss | 0 | 2013-03-21 15:56:00 | 2013-03-21 18:26:00 | 2013-03-21 16:15:21 2 | facebooking | 0 | 2013-03-21 20:48:00 | 2013-03-21 22:26:00 | 2013-03-21 16:15:21 (2 rows)
The logs do not contain any errors or further information. I have used a Remote Heroku PostgreSQL Database in both cases (Production and Local).
So why does this not work?